Documentation
¶
Index ¶
Constants ¶
View Source
const ( TaskTypePersistent uint8 = 0 TaskTypeScheduled uint8 = 1 ScheduleTypeInterval uint8 = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GenericTask ¶
func (*GenericTask) Name ¶
func (t *GenericTask) Name() string
func (*GenericTask) Schedule ¶
func (t *GenericTask) Schedule() Schedule
func (*GenericTask) Type ¶
func (t *GenericTask) Type() uint8
type GenericTaskHandler ¶
type GenericTaskHandler struct {
// contains filtered or unexported fields
}
func NewGenericTaskHandler ¶
func NewGenericTaskHandler(cfg GenericTaskHandlerConfig) *GenericTaskHandler
func (*GenericTaskHandler) Handle ¶
func (h *GenericTaskHandler) Handle(b broadcaster.Broadcaster)
func (*GenericTaskHandler) Register ¶
func (h *GenericTaskHandler) Register(name string, task Task)
Register adds a task to the handler. It must be called before Handle(). Calling Register after Handle() or registering the same task name twice will cause the program to exit via log.Fatalf.
func (*GenericTaskHandler) Stop ¶
func (h *GenericTaskHandler) Stop()
func (*GenericTaskHandler) Verify ¶
func (h *GenericTaskHandler) Verify() <-chan chan bool
type GenericTaskHandlerConfig ¶
type GenericTaskHandlerConfig struct {
}
type IntervalSchedule ¶
func (*IntervalSchedule) Next ¶
func (c *IntervalSchedule) Next() <-chan time.Time
func (*IntervalSchedule) Type ¶
func (*IntervalSchedule) Type() uint8
type Task ¶
type Task interface {
Name() string
Type() uint8
Schedule() Schedule
Run(ctx context.Context, b broadcaster.Broadcaster)
}
type TaskHandler ¶
type TaskHandler interface {
Handle(b broadcaster.Broadcaster)
Register(name string, task Task)
Stop()
Verify() <-chan chan bool
}
A TaskHandler runs in the context of a Leader Loop. When the leader loop ends, the TaskHandler stops. A TaskHandler can do two types of work:
- Persistent jobs that run for the duration of the TaskHandler's run loop. Persistent jobs, for instance, can monitor a channel and track heartbeats for macro transactions or in-progress queue work.
- Scheduled jobs that run periodically. Scheduled jobs have a set schedule and run per that schedule during the lifetime of the TaskHandler's run loop.
Click to show internal directories.
Click to hide internal directories.