Documentation ¶
Index ¶
- type Controller
- func (c *Controller) ComponentID() string
- func (c *Controller) ComponentName() string
- func (c *Controller) Disable(jobName string) error
- func (c *Controller) DisableAll() error
- func (c *Controller) Enable(jobName string) error
- func (c *Controller) EnableAll() error
- func (c *Controller) Execute(jobName string) error
- func (c *Controller) Register(j *job.Job)
- func (c *Controller) Schedule(cron string, jobName string) error
- func (c *Controller) Start()
- func (c *Controller) Stop()
- type IDGenerator
- type LockManager
- type Logger
- type Option
- type StatusManager
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the main point of this library.
func NewController ¶
func NewController(componentName, componentID string, idGenerator IDGenerator, lockManager LockManager, options ...Option) *Controller
NewController returns a new Controller.
func (*Controller) ComponentID ¶
func (c *Controller) ComponentID() string
ComponentID returns the ComponentID of the instance. This ID was computed thanks to the IDGenerator.
func (*Controller) ComponentName ¶
func (c *Controller) ComponentName() string
ComponentName returns the ComponentName of the instance.
func (*Controller) Disable ¶
func (c *Controller) Disable(jobName string) error
Disable execution for the specified job according to the LockManager policy implementation.
func (*Controller) DisableAll ¶
func (c *Controller) DisableAll() error
DisableAll disables execution for all jobs according to the LockManager policy implementation.
func (*Controller) Enable ¶
func (c *Controller) Enable(jobName string) error
Enable execution for the specified job.
func (*Controller) EnableAll ¶
func (c *Controller) EnableAll() error
EnableAll enables execution for all jobs.
func (*Controller) Execute ¶
func (c *Controller) Execute(jobName string) error
Execute trigger an immediate job execution. (Lock policy is still applied)
func (*Controller) Register ¶
func (c *Controller) Register(j *job.Job)
Register a new job. This method must be called first to be able to Schedule/Execute a job.
func (*Controller) Schedule ¶
func (c *Controller) Schedule(cron string, jobName string) error
Schedule a job execution according to a cron expression. See https://godoc.org/github.com/victorcoder/dkron/cron for cron expression syntax.
func (*Controller) Stop ¶
func (c *Controller) Stop()
Stop the cron. All the scheduled tasks will not be executed until Start() is called.
type IDGenerator ¶
type IDGenerator interface {
NextID() string
}
IDGenerator is used to compute a unique identifier for component instance and job execution instance.
type LockManager ¶
type LockManager interface { Enable(componentName string, jobName string) error Disable(componentName string, jobName string) error Lock(componentName, componentID, jobName, jobID string, jobMaxDuration time.Duration) error Unlock(componentName, componentID, jobName, jobID string) error }
LockManager is the lock policy to prevent concurrent job execution.
type Option ¶
type Option func(*Controller)
Option is used to configure the Controller. It takes on argument: the Controller we are operating on.
func EnableStatusStorage ¶
func EnableStatusStorage(statusManager StatusManager) Option
EnableStatusStorage is an option to provide a component for job execution information storage.
type StatusManager ¶
type StatusManager interface { Start(componentName, componentID, jobName string) error Update(componentName, componentID, jobName string, stepInfos map[string]string) error Complete(componentName, componentID, jobName, jobID string, stepInfos, message map[string]string) error Fail(componentName, componentID, jobName, jobID string, stepInfos, message map[string]string) error Register(componentName, componentID, jobName, jobID string) }
StatusManager is the component used to persist information about job executions.
Directories ¶
Path | Synopsis |
---|---|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
Package lock provides a mechanism for distributed locks.
|
Package lock provides a mechanism for distributed locks. |
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |