Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job interface { // ID returns the Job unique identifier ID() string // Run execute the job Run(ctx context.Context) error }
Job will be implemented by any job runner
type JobsScheduler ¶
type JobsScheduler struct {
// contains filtered or unexported fields
}
JobsScheduler implements Scheduler
func NewJobsScheduler ¶
func NewJobsScheduler() *JobsScheduler
NewJobsScheduler creates a new instance of Scheduler. It accepts for cronExpression
- Standard crontab specs, e.g. "* * * * ?"
- With optional second field, e.g. "* * * * * ?"
- Descriptors, e.g. "@midnight", "@every 1h30m"
func (*JobsScheduler) AddJob ¶
AddJob adds new Job to the scheduler. If the job already exists rejects the request.
func (*JobsScheduler) Run ¶
func (s *JobsScheduler) Run(ctx context.Context)
Run runs the scheduler by executing all jobs that have been added to it.
func (*JobsScheduler) Start ¶
func (s *JobsScheduler) Start(ctx context.Context)
Start starts the scheduler and run all the jobs in their separate go-routine
type Scheduler ¶
type Scheduler interface { // Start starts the scheduler and run all the jobs in their separate go-routine Start(ctx context.Context) // Stop stops the scheduler and stop any running job Stop(ctx context.Context) error // Run runs the scheduler by executing all jobs that have been added to it. Run(ctx context.Context) // AddJob add a new job runner to the scheduler. The jobID and cronExpression is required. // It accepts for cronExpression // - Standard crontab specs, e.g. "* * * * ?" // - With optional second field, e.g. "* * * * * ?" // - Descriptors, e.g. "@midnight", "@every 1h30m" AddJob(ctx context.Context, cronExpression string, job Job) error }
Scheduler will be implemented by the scheduler
Click to show internal directories.
Click to hide internal directories.