manager

package
v0.2.0-alpha.12 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobExistsError

type JobExistsError struct {
	JobName string
}

JobExistsError represents an error when a job already exists.

func (*JobExistsError) Error

func (e *JobExistsError) Error() string

type JobManager

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

JobManager manages cron jobs.

func NewJobManager

func NewJobManager(opts ...Option) *JobManager

NewJobManager creates a new instance of JobManager.

func (*JobManager) AddJob

func (jm *JobManager) AddJob(jobName string, schedule string, cmd cron.Job) (cron.EntryID, error)

AddJob adds a new cron job to the manager.

func (*JobManager) GetJobs

func (jm *JobManager) GetJobs() map[string]cron.EntryID

GetJobs returns a map of all the current cron jobs.

func (*JobManager) JobExists

func (jm *JobManager) JobExists(jobName string) bool

JobExists checks if a specific job exists in the manager.

func (*JobManager) RemoveJob

func (jm *JobManager) RemoveJob(jobName string) error

RemoveJob removes a specified cron job from the manager.

func (*JobManager) Start

func (jm *JobManager) Start()

Start starts the cron scheduler to begin executing jobs.

func (*JobManager) Stop

func (jm *JobManager) Stop() context.Context

Stop stops the cron scheduler.

func (*JobManager) UpdateJob

func (jm *JobManager) UpdateJob(jobName string, schedule string, cmd cron.Job) error

UpdateJob updates a specified cron job with a new schedule and function.

type JobNotFoundError

type JobNotFoundError struct {
	JobName string
}

JobNotFoundError represents an error when a job does not exist.

func (*JobNotFoundError) Error

func (e *JobNotFoundError) Error() string

Error implements the error interface for JobNotFoundError.

type Option

type Option func(jm *JobManager)

Option defines a function type that configures JobManager options.

func WithCron

func WithCron(c *cron.Cron) Option

WithCron is an Option that allows a custom cron scheduler to be set.

Jump to

Keyboard shortcuts

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