Documentation ¶
Index ¶
- Variables
- type CronJobExpr
- type CronjobRepository
- type JobDetails
- type RobfigCronjobRepository
- func (cj *RobfigCronjobRepository) ListJobs() ([]JobDetails, error)
- func (cj *RobfigCronjobRepository) RemoveJob(jobId string) error
- func (cj *RobfigCronjobRepository) ScheduleIntervalJob(timeExpr string, job func()) (jobId string, err error)
- func (cj *RobfigCronjobRepository) Start() error
- func (cj *RobfigCronjobRepository) Stop() error
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 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
Click to show internal directories.
Click to hide internal directories.