Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrJobNotFound = errors.New("job not found") ErrTooLate = errors.New("too late") ErrNotWithinExecutorGracePeriod = errors.New("job is not within executor grace period") )
View Source
var (
ErrExecutorIsClosed = errors.New("executor is closed")
)
Functions ¶
func NewExecutor ¶
func NewExecutor(jobCh chan<- *jobmodels.Job, gracePeriod time.Duration, accuracy time.Duration) *executorImpl
NewExecutor creates a new executor that will start dispatching jobs when the trigger time of the job is reached.
Refer executorImpl for more details.
func NewJobHeap ¶
func NewJobHeap() *jobHeap
Types ¶
type Executor ¶
type Executor interface {
// Queue adds the job to the execution queue.
// When the job is ready to be executed, it will be sent to the job channel.
Queue(job jobmodels.Job) error
// Delete deletes the queued job.
// If the job is not queued, it will return ErrJobNotFound
Delete(jobID string) error
// returns the job with the given jobID.
GetJob(jobId string) (job *jobmodels.Job, version int, deleted bool, err error)
// Close closes the executor and waits for all the jobs to finish executing.
Close()
}
Executor queues the jobs and runs them one by one. It also includes methods to delete or update the job so that you can change the job state when it is queued in the memory.
Click to show internal directories.
Click to hide internal directories.