Documentation
¶
Index ¶
- func Module() fx.Option
- 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) GetStatusRegistry() status.Registry
- func (jg *JobGroup) IsHealthy() bool
- func (jg *JobGroup) JobInfo(name string) (JobInfo, error)
- func (jg *JobGroup) RegisterJob(job Job, config jobsconfig.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, delay time.Duration)
- type JobGroupConfig
- type JobGroupConstructor
- type JobInfo
- type JobStats
- type JobWatcher
- type JobWatchers
- type MultiJob
- type MultiJobConfig
- type MultiJobConstructor
- type SelfChecksIn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BodyProvider ¶
type BodyProvider func() io.Reader
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 {
// contains filtered or unexported fields
}
HTTPJob wraps a basic job along with HTTPJobConfig to execute an HTTP job.
func (*HTTPJob) Execute ¶
func (job *HTTPJob) Execute(ctx context.Context) (proto.Message, error)
Execute executes the 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.
func NewBasicJob ¶
func NewBasicJob(name string, jobFunc JobCallback) Job
NewBasicJob is a constructor for basicJob struct.
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 ¶
type JobCallback func(context.Context) (proto.Message, error)
JobCallback is the callback function that is called after a job is executed.
type JobConfig ¶
type JobConfig = jobsconfig.JobConfig
JobConfig is reexported as it is commonly used when importing jobs package.
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,
config jobsconfig.JobGroupConfig,
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 ¶
func (jg *JobGroup) DeregisterJob(name string) error
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) GetStatusRegistry ¶
func (jg *JobGroup) GetStatusRegistry() status.Registry
GetStatusRegistry returns the registry of the JobGroup.
func (*JobGroup) IsHealthy ¶
func (jg *JobGroup) IsHealthy() bool
IsHealthy returns true if the job is healthy.
func (*JobGroup) JobInfo ¶
func (jg *JobGroup) JobInfo(name string) (JobInfo, error)
JobInfo returns the information related to a job with given name.
func (*JobGroup) RegisterJob ¶
func (jg *JobGroup) RegisterJob(job Job, config jobsconfig.JobConfig) error
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 ¶
func (jg *JobGroup) TriggerJob(name string, delay time.Duration)
TriggerJob triggers a Job in the JobGroup.
type JobGroupConfig ¶
type JobGroupConfig = jobsconfig.JobGroupConfig
JobGroupConfig is reexported as it is commonly used when importing jobs package.
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 jobsconfig.JobGroupConfig
}
JobGroupConstructor holds fields to create annotated instances of JobGroup.
type JobInfo ¶
type JobInfo struct {
LastExecuteTime time.Time
ExecuteCount int
}
JobInfo contains information such as run count, last run time, etc. for a Job.
type JobStats ¶
type JobStats struct {
Duration time.Duration
}
JobStats holds fields to track job statistics.
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(registry status.Registry, 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 ¶
func (mj *MultiJob) DeregisterJob(name string) error
DeregisterJob deregisters a job with the MultiJob.
func (*MultiJob) Execute ¶
func (mj *MultiJob) Execute(ctx context.Context) (proto.Message, error)
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 ¶
func (mj *MultiJob) RegisterJob(job Job) error
RegisterJob registers a job with the MultiJob.
type MultiJobConfig ¶
type MultiJobConfig struct {
jobsconfig.JobConfig
}
MultiJobConfig holds configuration for MultiJob. swagger:model
type MultiJobConstructor ¶
type MultiJobConstructor struct {
DefaultConfig MultiJobConfig
Name string
JobGroupName string
JWS JobWatchers
GWS GroupWatchers
}
MultiJobConstructor holds fields to create annotated instance of MultiJob.
type SelfChecksIn ¶
type SelfChecksIn struct {
fx.In
Liveness *MultiJob `name:"liveness.service"`
Readiness *MultiJob `name:"readiness.service"`
}
SelfChecksIn holds parameters for RegisterSelfChecks.