scheduler

package
v0.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler is a event scheduler that periodically inserts events into the event stream. It uses the cron syntax from https://github.com/gorhill/cronexpr.

func NewMiddleware

func NewMiddleware(ctx context.Context) (eh.EventHandlerMiddleware, *Scheduler)

NewMiddleware creates a new scheduler middleware that runs until the context is canceled.

func (*Scheduler) ScheduleEvent

func (s *Scheduler) ScheduleEvent(ctx context.Context, cronLine string, eventFunc func(time.Time) eh.Event) error

ScheduleEvent schedules an event to be sent on regular intervals, using a line in the crontab format to setup the timing. The eventFunc should create the event to send given the triggered time as input. Cancelling the context will stop the triggering of more events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL