Documentation ¶
Index ¶
- type BackgroundFunction
- type EventOption
- type JobName
- type Options
- type Request
- type Tickler
- func (s *Tickler) Enqueue(request Request, opts ...EventOption)
- func (s *Tickler) EnqueueWithContext(ctx context.Context, request Request, opts ...EventOption)
- func (s *Tickler) GetContext() context.Context
- func (s *Tickler) GetCurrentJobs() map[string]bool
- func (s *Tickler) GetQueueLength() int
- func (s *Tickler) Limit(newLimit int)
- func (s *Tickler) SetContext(ctx context.Context)
- func (s *Tickler) Start()
- func (s *Tickler) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackgroundFunction ¶
type BackgroundFunction = func() error
type EventOption ¶
type EventOption interface {
// contains filtered or unexported methods
}
func IfFailure ¶
func IfFailure(jobNames ...JobName) EventOption
IfFailure runs the given function if the job(s) fails.
func IfSuccess ¶
func IfSuccess(jobNames ...JobName) EventOption
IfSuccess runs the given function if the job(s) succeeds.
func WaitFor ¶
func WaitFor(jobNames ...JobName) EventOption
func WithRetry ¶
func WithRetry(maxRetries int) EventOption
WithRetry runs the given function with the given number of retries. It uses the truncated exponential backoff algorithm to determine the delay between retries.
type Request ¶
type Request struct { Job BackgroundFunction Name JobName }
Request is a request to be executed
type Tickler ¶
type Tickler struct {
// contains filtered or unexported fields
}
Tickler is a service that can be used to schedule and run the background tasks/jobs
func New ¶
func New() *Tickler
New creates a new Tickler with default settings. The Tickler will not start until the Start method is called.
func (*Tickler) Enqueue ¶
func (s *Tickler) Enqueue(request Request, opts ...EventOption)
func (*Tickler) EnqueueWithContext ¶
func (s *Tickler) EnqueueWithContext(ctx context.Context, request Request, opts ...EventOption)
func (*Tickler) GetContext ¶
GetContext returns the context of the tickler
func (*Tickler) GetCurrentJobs ¶
GetCurrentJobs returns a list of jobs that are currently running
func (*Tickler) GetQueueLength ¶
GetQueueLength returns the length of the queue
func (*Tickler) Limit ¶
Limit the number of jobs that can be run at the same time the default size is 100.
func (*Tickler) SetContext ¶
SetContext sets the context for the tickler