Documentation ¶
Index ¶
- func NextCronTime(now time.Time, cronStr string) (time.Duration, error)
- type AdhocRequestExecutor
- type CheckExecutor
- type CheckTimer
- type CheckWatcher
- type Config
- type CronScheduler
- type CronTimer
- type EntityCache
- type EntityCacheValue
- type Executor
- type IntervalScheduler
- type IntervalTimer
- type Option
- type RoundRobinCronScheduler
- type RoundRobinIntervalScheduler
- type Scheduler
- type SchedulerType
- type Schedulerd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdhocRequestExecutor ¶
type AdhocRequestExecutor struct {
// contains filtered or unexported fields
}
AdhocRequestExecutor takes new check requests from the adhoc queue and runs them
func NewAdhocRequestExecutor ¶
func NewAdhocRequestExecutor(ctx context.Context, store store.Store, queue types.Queue, bus messaging.MessageBus, cache *EntityCache) *AdhocRequestExecutor
NewAdhocRequestExecutor returns a new AdhocRequestExecutor.
func (*AdhocRequestExecutor) Stop ¶
func (a *AdhocRequestExecutor) Stop()
Stop calls the context cancel function to stop the AdhocRequestExecutor.
type CheckExecutor ¶
type CheckExecutor struct {
// contains filtered or unexported fields
}
CheckExecutor executes scheduled checks in the check scheduler
func NewCheckExecutor ¶
func NewCheckExecutor(bus messaging.MessageBus, namespace string, store store.Store, cache *EntityCache) *CheckExecutor
NewCheckExecutor creates a new check executor
type CheckTimer ¶
type CheckTimer interface { // C channel emits events when timer's duration has reached 0 C() <-chan time.Time // SetDuration updates the interval in which timers are set SetDuration(string, uint) // Start sets up a new timer Start() // Next reset's timer using interval Next() // Stop ends the timer Stop() }
A CheckTimer handles starting and stopping timers for a given check
type CheckWatcher ¶
type CheckWatcher struct {
// contains filtered or unexported fields
}
CheckWatcher manages all the check schedulers
func NewCheckWatcher ¶
func NewCheckWatcher(ctx context.Context, msgBus messaging.MessageBus, store store.Store, pool *ringv2.Pool, cache *EntityCache) *CheckWatcher
NewCheckWatcher creates a new ScheduleManager.
type Config ¶
type Config struct { Store store.Store QueueGetter types.QueueGetter RingPool *ringv2.Pool Bus messaging.MessageBus }
Config configures Schedulerd.
type CronScheduler ¶
type CronScheduler struct {
// contains filtered or unexported fields
}
IntervalScheduler schedules checks to be executed on a cron schedule.
func NewCronScheduler ¶
func NewCronScheduler(ctx context.Context, store store.Store, bus messaging.MessageBus, check *corev2.CheckConfig, cache *EntityCache) *CronScheduler
func (*CronScheduler) Interrupt ¶
func (s *CronScheduler) Interrupt(check *corev2.CheckConfig)
Interrupt refreshes the scheduler with a revised check config.
func (*CronScheduler) Start ¶
func (s *CronScheduler) Start()
func (*CronScheduler) Stop ¶
func (s *CronScheduler) Stop() error
func (*CronScheduler) Type ¶
func (s *CronScheduler) Type() SchedulerType
type CronTimer ¶
type CronTimer struct {
// contains filtered or unexported fields
}
A CronTimer handles starting and stopping timers for a given check
func NewCronTimer ¶
NewCronTimer establishes new check timer given a name & an initial interval
func (*CronTimer) SetDuration ¶
SetDuration updates the interval in which timers are set
type EntityCache ¶
type EntityCache struct {
// contains filtered or unexported fields
}
EntityCache is a cache of entities. The cache uses a watcher on entities in order to keep itself up to date. Entities can be efficiently retrieved from the cache by namespace.
func NewEntityCache ¶
func NewEntityCache(ctx context.Context, s store.EntityStore) (*EntityCache, error)
NewEntityCache creates a new EntityCache. It retrieves all entities from the store on creation.
func (*EntityCache) GetEntities ¶
func (e *EntityCache) GetEntities(namespace string) []EntityCacheValue
GetEntities gets all entities in a namespace.
func (*EntityCache) Watch ¶
func (e *EntityCache) Watch(ctx context.Context) <-chan struct{}
Watch allows cache users to get notified when the cache has new values. When the context is canceled, the channel will be closed.
type EntityCacheValue ¶
EntityCacheValue contains an entity, and its synthesized companion.
type Executor ¶
type Executor interface {
// contains filtered or unexported methods
}
Executor executes scheduled or adhoc checks
type IntervalScheduler ¶
type IntervalScheduler struct {
// contains filtered or unexported fields
}
IntervalScheduler schedules checks to be executed on a timer
func NewIntervalScheduler ¶
func NewIntervalScheduler(ctx context.Context, store store.Store, bus messaging.MessageBus, check *types.CheckConfig, cache *EntityCache) *IntervalScheduler
func (*IntervalScheduler) Interrupt ¶
func (s *IntervalScheduler) Interrupt(check *corev2.CheckConfig)
Interrupt refreshes the scheduler with a revised check config.
func (*IntervalScheduler) Start ¶
func (s *IntervalScheduler) Start()
Start starts the IntervalScheduler.
func (*IntervalScheduler) Stop ¶
func (s *IntervalScheduler) Stop() error
Stop stops the IntervalScheduler
func (*IntervalScheduler) Type ¶
func (s *IntervalScheduler) Type() SchedulerType
type IntervalTimer ¶
type IntervalTimer struct {
// contains filtered or unexported fields
}
A IntervalTimer handles starting a stopping timers for a given check
func NewIntervalTimer ¶
func NewIntervalTimer(name string, interval uint) *IntervalTimer
NewIntervalTimer establishes new check timer given a name & an initial interval
func (*IntervalTimer) C ¶
func (timerPtr *IntervalTimer) C() <-chan time.Time
C channel emits events when timer's duration has reached 0
func (*IntervalTimer) Next ¶
func (timerPtr *IntervalTimer) Next()
Next reset's timer using interval
func (*IntervalTimer) SetDuration ¶
func (timerPtr *IntervalTimer) SetDuration(cron string, interval uint)
SetDuration updates the interval in which timers are set
type RoundRobinCronScheduler ¶
type RoundRobinCronScheduler struct {
// contains filtered or unexported fields
}
RoundRobinCronScheduler is like CronScheduler, but only schedules checks on a single entity at a time.
func NewRoundRobinCronScheduler ¶
func NewRoundRobinCronScheduler(ctx context.Context, store store.Store, bus messaging.MessageBus, pool *ringv2.Pool, check *corev2.CheckConfig, cache *EntityCache) *RoundRobinCronScheduler
NewRoundRobinCronScheduler creates a new RoundRobinCronScheduler.
func (*RoundRobinCronScheduler) Interrupt ¶
func (s *RoundRobinCronScheduler) Interrupt(check *corev2.CheckConfig)
Interrupt refreshes the scheduler with a revised check config.
func (*RoundRobinCronScheduler) Start ¶
func (s *RoundRobinCronScheduler) Start()
Start starts the scheduler.
func (*RoundRobinCronScheduler) Stop ¶
func (s *RoundRobinCronScheduler) Stop() error
Stop stops the scheduler
func (*RoundRobinCronScheduler) Type ¶
func (s *RoundRobinCronScheduler) Type() SchedulerType
Type returns RoundRobinCronType
type RoundRobinIntervalScheduler ¶
type RoundRobinIntervalScheduler struct {
// contains filtered or unexported fields
}
func NewRoundRobinIntervalScheduler ¶
func NewRoundRobinIntervalScheduler(ctx context.Context, store store.Store, bus messaging.MessageBus, pool *ringv2.Pool, check *corev2.CheckConfig, cache *EntityCache) *RoundRobinIntervalScheduler
func (*RoundRobinIntervalScheduler) Interrupt ¶
func (s *RoundRobinIntervalScheduler) Interrupt(check *corev2.CheckConfig)
Interrupt refreshes the scheduler with a revised check config.
func (*RoundRobinIntervalScheduler) Start ¶
func (s *RoundRobinIntervalScheduler) Start()
func (*RoundRobinIntervalScheduler) Stop ¶
func (s *RoundRobinIntervalScheduler) Stop() error
Stop stops the scheduler
func (*RoundRobinIntervalScheduler) Type ¶
func (s *RoundRobinIntervalScheduler) Type() SchedulerType
type Scheduler ¶
type Scheduler interface { // Start stops the scheduler. Start() // Stop stops the scheduler. Stop() error // Interrupt refreshes the state of the scheduler. Interrupt(*corev2.CheckConfig) // Type returns the scheduler type Type() SchedulerType }
Scheduler is a check scheduler. It is responsible for determining the scheduling interval of a check, given a particular configuration. After Start(), the scheduler is active and will continue to schedule a check according to its schedule. When Interrupt is called, the schedule will be recalculated.
type SchedulerType ¶
type SchedulerType int
const ( IntervalType SchedulerType = iota CronType RoundRobinIntervalType RoundRobinCronType )
func GetSchedulerType ¶
func GetSchedulerType(check *corev2.CheckConfig) SchedulerType
GetSchedulerType gets the SchedulerType for a given check config.
func (SchedulerType) String ¶
func (s SchedulerType) String() string
type Schedulerd ¶
type Schedulerd struct {
// contains filtered or unexported fields
}
Schedulerd handles scheduling check requests for each check's configured interval and publishing to the message bus.
func (*Schedulerd) Err ¶
func (s *Schedulerd) Err() <-chan error
Err returns a channel on which to listen for terminal errors.