scheduler

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID    cron.EntryID
	Entry cron.Entry
}

type Runner

type Runner = func(subreddit string)

type Scheduler

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

func New

func New(runner Runner) *Scheduler

func (*Scheduler) Delete

func (scheduler *Scheduler) Delete(subreddit string)

Delete removes a job from the scheduler.

If job does not exist, it will be a no-op.

func (*Scheduler) Get

func (scheduler *Scheduler) Get(subreddit string) *Job

Get returns the job for the given subreddit.

Returns nil if the subreddit is not found or active.

func (*Scheduler) Iter

func (scheduler *Scheduler) Iter(f func(string, *Job) bool)

func (*Scheduler) List

func (scheduler *Scheduler) List() map[string]*Job

List returns a copy of the list of jobs.

func (*Scheduler) Put

func (scheduler *Scheduler) Put(subreddit string, schedule string) (job *Job, err error)

Put adds a job to the scheduler.

If job already exists, it will be replaced.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start starts the scheduler in the background.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler.

func (*Scheduler) Sync

func (scheduler *Scheduler) Sync(ctx context.Context, db bob.Executor) (err error)

Sync empties the scheduler and re-adds all enabled jobs from the database.

This is costly but ensures that the scheduler is in sync with the database.

For simpler operation consider using Put and Delete instead.

Jump to

Keyboard shortcuts

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