schedule

package
v0.0.0-...-af74388 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrScheduleFailed = errors.New("failed to schedule job")
	ErrJobNotFound    = errors.New("job id not found")
)

Functions

This section is empty.

Types

type CronJobExpr

type CronJobExpr string

type CronjobRepository

type CronjobRepository interface {
	ScheduleIntervalJob(timeExpr string, job func()) (jobID string, err error)
	RemoveJob(jobID string) error
	Start() error
	Stop() error
	ListJobs() ([]JobDetails, error)
}

type JobDetails

type JobDetails struct {
	JobId   string
	NextRun time.Time
	LastRun time.Time
}

type RobfigCronjobRepository

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

func GetRobfigSchedulerInstance

func GetRobfigSchedulerInstance() *RobfigCronjobRepository

GetRobfigSchedulerInstance returns the singleton instance of RobfigCronjobRepository.

func (*RobfigCronjobRepository) ListJobs

func (cj *RobfigCronjobRepository) ListJobs() ([]JobDetails, error)

func (*RobfigCronjobRepository) RemoveJob

func (cj *RobfigCronjobRepository) RemoveJob(jobId string) error

func (*RobfigCronjobRepository) ScheduleIntervalJob

func (cj *RobfigCronjobRepository) ScheduleIntervalJob(timeExpr string, job func()) (jobId string, err error)

ScheduleIntervalJob schedules a recurring job at intervals defined by the provided time expression (`timeExpr`).

Parameters:

  • timeExpr: A string defining the interval at which the job should run. The format is similar to "1h", "30m", "15s" for hours, minutes, and seconds respectively.
  • job: A function that will be executed at the specified interval.

Returns:

  • jobId: A unique string identifier for the scheduled job. If scheduling fails, this will be an empty string.
  • err: An error if scheduling fails. Possible reasons include invalid `timeExpr` or issues with the scheduler.

Notes:

  • If `timeExpr` is invalid, an error will be returned.
  • If the job scheduling fails, an error is returned along with an empty `jobId`.
  • This method is thread-safe; it uses a mutex to protect shared resources.

func (*RobfigCronjobRepository) Start

func (cj *RobfigCronjobRepository) Start() error

func (*RobfigCronjobRepository) Stop

func (cj *RobfigCronjobRepository) Stop() error

Jump to

Keyboard shortcuts

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