Documentation ¶
Index ¶
- func Module() fx.Option
- type BasicJob
- type BodyProvider
- type GroupWatcher
- type GroupWatchers
- type HTTPJob
- type HTTPJobConfig
- type Job
- type JobBase
- type JobCallback
- type JobConfig
- type JobGroup
- func (jg *JobGroup) DeregisterAll()
- func (jg *JobGroup) DeregisterJob(name string) error
- func (jg *JobGroup) GetRegistry() status.Registry
- func (jg *JobGroup) IsHealthy() bool
- func (jg *JobGroup) JobInfo(name string) *JobInfo
- func (jg *JobGroup) RegisterJob(job Job, config JobConfig) error
- func (jg *JobGroup) Results() (*statusv1.GroupStatus, bool)
- func (jg *JobGroup) Start() error
- func (jg *JobGroup) Stop() error
- func (jg *JobGroup) TriggerJob(name string)
- type JobGroupConfig
- type JobGroupConstructor
- type JobInfo
- type JobStats
- type JobWatcher
- type JobWatchers
- type MultiJob
- type MultiJobConfig
- type MultiJobConstructor
- type SchedulerConfig
- type SchedulerMode
- type SelfChecksIn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BasicJob ¶
type BasicJob struct { JobFunc JobCallback JobBase }
BasicJob is a basic job that every other job builds on.
func (*BasicJob) JobWatchers ¶
func (job *BasicJob) JobWatchers() JobWatchers
JobWatchers returns the job watchers.
type BodyProvider ¶
BodyProvider allows the users to provide a body to the HTTP jobs. For example for posting a payload as a job.
type GroupWatcher ¶
type GroupWatcher interface { OnJobRegistered(name string) OnJobDeregistered(name string) OnJobScheduled(name string) OnJobCompleted(name string, status *statusv1.Status, jobStats JobStats) }
GroupWatcher is used for tracking completion of JobGroup.
type GroupWatchers ¶
type GroupWatchers []GroupWatcher
GroupWatchers is a collection of GroupWatcher.
func (GroupWatchers) OnJobCompleted ¶
func (gws GroupWatchers) OnJobCompleted(name string, status *statusv1.Status, jobStats JobStats)
OnJobCompleted calls OnJobCompleted for each GroupWatcher in the collection.
func (GroupWatchers) OnJobDeregistered ¶
func (gws GroupWatchers) OnJobDeregistered(name string)
OnJobDeregistered calls OnJobDeregistered for each GroupWatcher in the collection.
func (GroupWatchers) OnJobRegistered ¶
func (gws GroupWatchers) OnJobRegistered(name string)
OnJobRegistered calls OnJobRegistered for each GroupWatcher in the collection.
func (GroupWatchers) OnJobScheduled ¶
func (gws GroupWatchers) OnJobScheduled(name string)
OnJobScheduled calls OnJobScheduled for each GroupWatcher in the collection.
type HTTPJob ¶
type HTTPJob struct { BasicJob // contains filtered or unexported fields }
HTTPJob wraps a basic job along with HTTPJobConfig to execute an HTTP job.
func (*HTTPJob) JobWatchers ¶
func (job *HTTPJob) JobWatchers() JobWatchers
JobWatchers returns the job watchers for the job.
type HTTPJobConfig ¶
type HTTPJobConfig struct { Client *http.Client Body BodyProvider URL string Method string ExpectedBody string Name string ExpectedStatus int }
HTTPJobConfig is the configuration for an HTTP job.
type Job ¶
type Job interface { // Returns the name Name() string // Executes the job Execute(ctx context.Context) (proto.Message, error) // JobWatchers JobWatchers() JobWatchers }
Job interface and basic job implementation.
type JobBase ¶
type JobBase struct { JobName string JWS JobWatchers }
JobBase is the base job implementation.
func (JobBase) JobWatchers ¶
func (job JobBase) JobWatchers() JobWatchers
JobWatchers returns the job watchers.
type JobCallback ¶
JobCallback is the callback function that is called after a job is executed.
type JobConfig ¶
type JobConfig struct { // Initial delay to start the job. Zero value will schedule the job immediately. Negative value will wait for next scheduled interval. InitialDelay config.Duration `json:"initial_delay" default:"0s"` // Time period between job executions. Zero or negative value means that the job will never execute periodically. ExecutionPeriod config.Duration `json:"execution_period" default:"10s"` // Execution timeout ExecutionTimeout config.Duration `json:"execution_timeout" validate:"gte=0s" default:"5s"` // Sets whether the job is initially healthy InitiallyHealthy bool `json:"initially_healthy" default:"false"` }
JobConfig is config for Job swagger:model
type JobGroup ¶
type JobGroup struct {
// contains filtered or unexported fields
}
JobGroup tracks a group of jobs. It is responsible for scheduling jobs and keeping track of their statuses.
func NewJobGroup ¶
func NewJobGroup( statusRegistry status.Registry, maxConcurrentJobs int, schedulerMode SchedulerMode, gws GroupWatchers, ) (*JobGroup, error)
NewJobGroup creates a new JobGroup.
func (*JobGroup) DeregisterAll ¶
func (jg *JobGroup) DeregisterAll()
DeregisterAll deregisters all Jobs from the JobGroup.
func (*JobGroup) DeregisterJob ¶
DeregisterJob deregisters a Job from the JobGroup. It returns an error if the job is not registered. It also stops the job's executor.
func (*JobGroup) GetRegistry ¶
GetRegistry returns the registry of the JobGroup.
func (*JobGroup) RegisterJob ¶
RegisterJob registers a new Job in a JobGroup. It returns an error if the job is already registered. It also starts the job's executor.
func (*JobGroup) Results ¶
func (jg *JobGroup) Results() (*statusv1.GroupStatus, bool)
Results returns the results of all jobs in the JobGroup.
func (*JobGroup) TriggerJob ¶
TriggerJob triggers a Job in the JobGroup.
type JobGroupConfig ¶
type JobGroupConfig struct {
SchedulerConfig
}
JobGroupConfig holds configuration for JobGroup. swagger:model
type JobGroupConstructor ¶
type JobGroupConstructor struct { // Name of the job group - config key is <name> and statuses are updated under <name>.<job> Name string // Config key -- if it is empty then it is <name>.scheduler Key string GW GroupWatchers DefaultConfig JobGroupConfig SchedulerMode SchedulerMode }
JobGroupConstructor holds fields to create annotated instances of JobGroup.
func (JobGroupConstructor) Annotate ¶
func (jgc JobGroupConstructor) Annotate() fx.Option
Annotate provides annotated instances of JobGroup.
type JobWatcher ¶
type JobWatcher interface { OnJobScheduled() OnJobCompleted(status *statusv1.Status, stats JobStats) }
JobWatcher is used for tracking completion of Job.
type JobWatchers ¶
type JobWatchers []JobWatcher
JobWatchers is a collection of JobWatcher.
func (JobWatchers) OnJobCompleted ¶
func (jws JobWatchers) OnJobCompleted(status *statusv1.Status, jobStats JobStats)
OnJobCompleted calls OnJobCompleted for each JobWatcher in the collection.
func (JobWatchers) OnJobScheduled ¶
func (jws JobWatchers) OnJobScheduled()
OnJobScheduled calls OnJobScheduled for each JobWatcher in the collection.
type MultiJob ¶
type MultiJob struct { JobBase // contains filtered or unexported fields }
MultiJob runs multiple jobs in asynchronous manner.
func NewMultiJob ¶
func NewMultiJob(name string, alwaysHealthy bool, jws JobWatchers, gws GroupWatchers) *MultiJob
NewMultiJob creates a new instance of MultiJob.
func (*MultiJob) DeregisterAll ¶
func (mj *MultiJob) DeregisterAll()
DeregisterAll removes all jobs from the MultiJob.
func (*MultiJob) DeregisterJob ¶
DeregisterJob deregisters a job with the MultiJob.
func (*MultiJob) Execute ¶
Execute executes all jobs, collects that results, and returns the aggregated status.
func (*MultiJob) JobWatchers ¶
func (mj *MultiJob) JobWatchers() JobWatchers
JobWatchers returns the list of job watchers.
func (*MultiJob) RegisterJob ¶
RegisterJob registers a job with the MultiJob.
type MultiJobConfig ¶
type MultiJobConfig struct { JobConfig // Sets whether the job is always passing AlwaysHealthy bool `json:"always_healthy" default:"false"` }
MultiJobConfig holds configuration for MultiJob. swagger:model
type MultiJobConstructor ¶
type MultiJobConstructor struct { Name string JobGroupName string JWS JobWatchers GWS GroupWatchers DefaultConfig MultiJobConfig }
MultiJobConstructor holds fields to create annotated instance of MultiJob.
func (MultiJobConstructor) Annotate ¶
func (mjc MultiJobConstructor) Annotate() fx.Option
Annotate provides annotated instance of MultiJob.
type SchedulerConfig ¶
type SchedulerConfig struct { // Limits how many jobs can be running at the same time. This is useful when running resource intensive jobs and a precise start time is not critical. 0 = no limit. MaxConcurrentJobs int `json:"max_concurrent_jobs" validate:"gte=0" default:"0"` }
SchedulerConfig holds configuration for job Scheduler. swagger:model
type SchedulerMode ¶
type SchedulerMode int8
SchedulerMode configures the scheduler's behavior when concurrency limit is applied.
const ( // RescheduleMode - the default is that if a limit on maximum // concurrent jobs is set and the limit is reached, a job will // skip it's run and try again on the next occurrence in the schedule. RescheduleMode SchedulerMode = iota // WaitMode - if a limit on maximum concurrent jobs is set // and the limit is reached, a job will wait to try and run // until a spot in the limit is freed up. // // Note: this mode can produce unpredictable results as // job execution order isn't guaranteed. For example, a job that // executes frequently may pile up in the wait queue and be executed // many times back to back when the queue opens. WaitMode )