manager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 4 Imported by: 0

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