cron

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LastEnqueueTimeFormat = "2006-01-02 15:04:05 -0700"

Variables

This section is empty.

Functions

func CronEntryFromMap

func CronEntryFromMap(m map[string]string) (*cronEntry, error)

func NewCronEntry

func NewCronEntry(name, desc, cron string, status EntryStatus, queuePrefix, queueDelimiter string, args []interface{}, job Job) (*cronEntry, error)

Types

type Cron

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

func NewCron

func NewCron(m *sidekiq.Manager, log Logger) *Cron

NewCron creates a new instance of the cron manager. You can use the Cron object to add and remove cron entries and to start polling. NewCron expects a valid sidekiq manager which it will use to interact with redis, and to enqueue jobs with. log can optionally be set, and will delegate logging to the passed in object if it is not nil.

func (*Cron) AddCron

func (c *Cron) AddCron(ctx context.Context, e *cronEntry) error

AddCron adds a cron entry to sidekiq. If the cron entry already exists, its state will be updated.

func (*Cron) CronEntries

func (c *Cron) CronEntries(ctx context.Context) ([]*cronEntry, error)

CronEntries returns all of the entries associated with the sidekiq instance.

func (*Cron) Enqueue

func (c *Cron) Enqueue(ctx context.Context, entry *cronEntry, forTime time.Time) bool

Enqueue adds a job to sidekiq and updates the cron entry with the enqueue time.

func (*Cron) Poll

func (c *Cron) Poll(ctx context.Context, interval time.Duration)

type EntryStatus

type EntryStatus string
const (
	Enabled  EntryStatus = "enabled"
	Disabled EntryStatus = "disabled"
)

type Job

type Job struct {
	Retry string        `json:"retry"`
	Queue string        `json:"queue"`
	Class string        `json:"class"`
	Args  []interface{} `json:"args"`
}

func (Job) SafeArgs

func (j Job) SafeArgs() []interface{}

type Logger

type Logger interface {
	Printf(format string, v ...any)
	Println(v ...any)
}

Jump to

Keyboard shortcuts

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