Documentation ¶
Index ¶
- Variables
- type Client
- func (clnt *Client) Cancel(ctx context.Context, path, body string) error
- func (clnt *Client) Disable(ctx context.Context, path, body string) (*Job, error)
- func (clnt *Client) Enable(ctx context.Context, path, body string) (*Job, error)
- func (clnt *Client) Get(ctx context.Context, path, body string) (*Job, error)
- func (clnt *Client) List(ctx context.Context, path, sortBy string, reverse bool, limit int64) (jobs []Job, cursor string, err error)
- func (clnt *Client) ListContinue(ctx context.Context, cursor string) (jobs []Job, nextCursor string, err error)
- func (clnt *Client) Schedule(ctx context.Context, path, body string, opts ...ScheduleOpt) (*Job, error)
- func (clnt *Client) Status(ctx context.Context) (*Status, error)
- type ClientOpt
- type Config
- type Dalga
- type Job
- type ScheduleOpt
- func MustWithIntervalString(s string) ScheduleOpt
- func MustWithLocationName(n string) ScheduleOpt
- func WithFirstRun(t time.Time) ScheduleOpt
- func WithImmediate() ScheduleOpt
- func WithInterval(d duration.Duration) ScheduleOpt
- func WithLocation(l *time.Location) ScheduleOpt
- func WithOneOff() ScheduleOpt
- type Status
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ Jobs: jobsConfig{ RetryInterval: time.Minute, RetryMultiplier: 1, RetryMaxInterval: time.Minute, ScanFrequency: time.Second, MaxRunning: 100, }, MySQL: mysqlConfig{ Host: "127.0.0.1", Port: 3306, DB: "test", Table: "dalga", User: "root", Password: "", MaxOpenConns: 50, SkipLocked: true, TransactionIsolationParamName: "transaction_isolation", DialTimeout: 30 * time.Second, ReadTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second, }, Listen: listenConfig{ Host: "127.0.0.1", Port: 34006, ShutdownTimeout: 10 * time.Second, IdleTimeout: 60 * time.Second, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, }, Endpoint: endpointConfig{ BaseURL: "http://127.0.0.1:5000/", Timeout: 10 * time.Second, }, }
DefaultConfig contains sensible defaults for Dalga instance. For a simple deployment, you only need to override MySQL options.
var ErrNotExist = table.ErrNotExist
ErrNotExist is returned when requested job does not exist.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { BaseURL string // contains filtered or unexported fields }
Client is used to interact with a Dalga cluster using REST.
func (*Client) Disable ¶
Disable stops the job with path and body from running at its scheduled times.
func (*Client) Enable ¶
Enable allows the job with path and body to continue running at its scheduled times.
If the next scheduled run is still in the future, the job will execute at that point. If the scheduled run is now in the past, the behavior depends upon the value of the FixedIntervals setting:
If FixedIntervals is false, the job will run immediately.
If FixedIntervals is true, the job will reschedule to the next appropriate point in the future based on its interval setting, effectively skipping the scheduled runs that were missed while the job was disabled.
func (*Client) ListContinue ¶ added in v4.0.1
type ClientOpt ¶
type ClientOpt func(c *Client)
ClientOpt is an option that can be provided to a Dalga client.
func WithClient ¶
WithClient provides a specific HTTP client.
type Config ¶
type Config struct { Jobs jobsConfig MySQL mysqlConfig Listen listenConfig Endpoint endpointConfig }
Config values for Dalga instance.
type Dalga ¶
type Dalga struct { Jobs *jobmanager.JobManager // contains filtered or unexported fields }
Dalga is a job scheduler.
func (*Dalga) CreateTable ¶
CreateTable creates the table for storing jobs on database.
func (*Dalga) NotifyDone ¶
func (d *Dalga) NotifyDone() chan struct{}
NotifyDone returns a channel that will be closed when Run method returns.
type ScheduleOpt ¶
type ScheduleOpt func(o *jobmanager.ScheduleOptions)
ScheduleOpt is an option that can be provided to the Schedule method.
func MustWithIntervalString ¶
func MustWithIntervalString(s string) ScheduleOpt
MustWithIntervalString is identical to WithInterval, except that it performs a parsing step. It panics if s is not a valid ISO8601 duration.
func MustWithLocationName ¶
func MustWithLocationName(n string) ScheduleOpt
MustWithLocationName is identical to WithLocation, except that it performs a parsing step. It panics if n is not a valid *time.Location name.
func WithFirstRun ¶
func WithFirstRun(t time.Time) ScheduleOpt
WithFirstRun specifies the job's first scheduled execution time. It's incompatible with the WithImmediate option.
The timezone of t is used when computing the first execution's instant in time, but subsequent intervals are computed within the timezone specified by the job's location.
If neither WithFirstRun or WithImmediate are used, the job's initial run will occur after one interval has elapsed.
func WithImmediate ¶
func WithImmediate() ScheduleOpt
WithImmediate specifies that the job should run immediately. It's incompatible with the WithFirstRun option.
If neither WithFirstRun or WithImmediate are used, the job's initial run will occur after one interval has elapsed.
func WithInterval ¶
func WithInterval(d duration.Duration) ScheduleOpt
WithInterval specifies that a job should recur, with frequency given as an ISO8601 duration as an interval: https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
This option is incompatible with the WithOneOff option.
func WithLocation ¶
func WithLocation(l *time.Location) ScheduleOpt
WithLocation specifies what location a job's schedule should be relative to. This is solely relevant for calculating intervals using an ISO8601 duration, since "P1D" can mean 23 or 25 hours of real time if the job's location is undergoing a daylight savings shift within that period.
Note that Dalga will not double-execute a job if it's scheduled at a time that repeats itself during a daylight savings shift, since it doesn't use wall clock time.
If this option is omitted, the job will default to UTC as a location.
func WithOneOff ¶
func WithOneOff() ScheduleOpt
WithOneOff specifies that the job should run once and then delete itself. It's incompatible with the WithInterval option.