v2 – github.com/vgarvardt/gueron/v2 Index | Files

package gueron

import "github.com/vgarvardt/gueron/v2"

Index

Types

type Scheduler

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

Scheduler responsible for collecting period tasks and generating gue.Job list for defined period of time.

func NewScheduler

func NewScheduler(pool adapter.ConnPool, opts ...SchedulerOption) (*Scheduler, error)

NewScheduler builds new Scheduler instance. Note that internally Scheduler uses gue.Client with the backoff set to gue.BackoffNever, so any errored job will be discarded immediately - this is how original cron works.

func (*Scheduler) Add

func (s *Scheduler) Add(spec, jobType string, args []byte) (*Scheduler, error)

Add adds new periodic task information to the Scheduler. Parameters are:

func (*Scheduler) MustAdd

func (s *Scheduler) MustAdd(spec, jobType string, args []byte) *Scheduler

MustAdd is the same as Scheduler.Add but instead of returning an error it panics.

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context, wm gue.WorkMap, poolSize int, options ...gue.WorkerPoolOption) error

Run initializes cron jobs and gue.WorkerPool that handles them. Run blocks until all workers exit. Use context cancellation for shutdown. WorkerMap parameter must have all the handlers that are going to handle cron jobs. Note that some gue.WorkerPoolOption will be overridden by Scheduler, they are:

type SchedulerOption

type SchedulerOption func(s *Scheduler)

SchedulerOption is the Scheduler builder options

func WithHorizon

func WithHorizon(d time.Duration) SchedulerOption

WithHorizon sets the scheduler cron jobs scheduling horizon. The more often the app is being redeployed/restarted the shorter the schedule horizon should be as rescheduling causes stop-the-world situation, so the fewer jobs to schedule or the shorter the horizon - the quicker the crons are ready to perform the duties.

func WithLogger

func WithLogger(logger adapter.Logger) SchedulerOption

WithLogger sets logger that will be used both for scheduler and gue.Client log

func WithMeter

func WithMeter(meter metric.Meter) SchedulerOption

WithMeter sets metric.Meter to the underlying gue.Client.

func WithPollInterval

func WithPollInterval(d time.Duration) SchedulerOption

WithPollInterval sets custom scheduler jobs poll interval.

func WithQueueName

func WithQueueName(qName string) SchedulerOption

WithQueueName sets custom scheduler queue name

Source Files

scheduler.go scheduler_option.go

Version
v2.1.0
Published
Mar 6, 2023
Platform
windows/amd64
Imports
16 packages
Last checked
now

Tools for package owners.