Documentation
¶
Index ¶
- Constants
- Variables
- func InitPrometheus(reg prometheus.Registerer)
- type Config
- type Job
- type JobFn
- type Priority
- func (s *Priority) Done() <-chan struct{}
- func (s *Priority) Health() health.Reporter
- func (s *Priority) Name() string
- func (s *Priority) Next(ctx context.Context) (TimedJob, bool)
- func (s *Priority) Start()
- func (s *Priority) Stop()
- func (s *Priority) Submit(task TimedJob) error
- func (s *Priority) Wait(ctx context.Context) error
- func (s *Priority) Work() <-chan TimedJob
- type Task
- type TimedJob
Constants ¶
View Source
const ( // Default health ticker period. DefaultHealthTickPeriod time.Duration = 1 * time.Second // Default channel buffer size. // // This should be sufficiently big enough to prevent blocking. DefaultChannelBufferSize int = 256 )
View Source
const ( // Number of seconds before a task is considered late. LateTaskDelay time.Duration = 5 * time.Second )
Variables ¶
Functions ¶
func InitPrometheus ¶
func InitPrometheus(reg prometheus.Registerer)
Initialise Prometheus metrics for this module.
Types ¶
type Config ¶
type Config struct {
Name string // Scheduler name.
HealthTickPeriod time.Duration // Health tick period.
Health health.Reporter // Health status reporter.
Prometheus prometheus.Registerer // Prometheus registerer.
AddBuffer int // Size of `add` buffer.
WorkBuffer int // Size of `work` buffer.
}
Scheduler configuration.
func NewConfig ¶
func NewConfig( name string, tick time.Duration, hlth health.Reporter, addBuff, workBuff int, ) *Config
Create a new scheduler configuration instance.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
Create a new default scheduler configuration instance.
type Job ¶
type Job interface {
Validate() error
Resolve(context.Context) error
Object() Task
Function() JobFn
}
type Priority ¶
type Priority struct {
// contains filtered or unexported fields
}
Priority scheduler
Instance is single-use; create a new instance to restart.
func NewPriority ¶
Return a new priority scheduler instance.
func (*Priority) Done ¶
func (s *Priority) Done() <-chan struct{}
Has the priority scheduler done processing?
func (*Priority) Start ¶
func (s *Priority) Start()
Start the scheduler.
Must be called once before use.
type TimedJob ¶
func InsertTimedJob ¶
Insert a timed job into a list of jobs.
Click to show internal directories.
Click to hide internal directories.