Versions in this module Expand all Collapse all v0 v0.2.0 Jul 6, 2021 Changes in this version + var ExecutionAlreadyWaiting = fmt.Errorf("Job already has an execution waiting%w", JobConditionalErr) + var JobConditionalErr = errors.New("") + var JobNoStartTime = fmt.Errorf("Job has no start time%w", JobConditionalErr) + var JobNotActive = fmt.Errorf("Job is not active%w", JobConditionalErr) + var JobNotDue = errors.New("Job not due") + var JobNotFound = fmt.Errorf("Job not found%w", JobConditionalErr) + var JobNotMine = errors.New("Job does not belong to this worker") + var JobTaskUnknown = func(taskName string) error + var OneShotJobUsed = fmt.Errorf("Job is one-shot and has already ran or been scheduled%w", JobConditionalErr) + var UnknownJobStatus = func(status ExecutionStatus) error + type Config struct + AppName string + DBHost string + DBName string + DBPass string + DBUser string + func BuildConfig(appName string) Config + func (c Config) DBDsn() string + type Controller struct + LoopSeconds float64 + func NewController(r *Repository) *Controller + func (c *Controller) Block(seconds int) + func (c *Controller) FinishTaskForJob(jobID uuid.UUID) error + func (c *Controller) JobFinishingMiddleware(next bus.CommandHandler) bus.CommandHandler + func (c *Controller) RegisterQueueAction(qa queueAction) + func (c *Controller) Run(done chan bool) + type ExecutionStatus string + const COMPLETE + const NONE + const PROCESSING + const WAITING + type Job struct + Active bool + CreatedAt time.Time + Executions []JobExecution + Frequency int + Heartbeat time.Time + ID uuid.UUID + Name string + StartAt time.Time + SystemJob bool + Task []byte + UserID uuid.UUID + Worker uuid.UUID + func NewJob(name string, cmd bus.Command) Job + func (j *Job) Complete(workerID uuid.UUID) error + func (j *Job) ScheduleNextExecution() error + func (j *Job) ScheduleNow() error + func (j Job) IsDue() bool + func (j Job) NextExecution() *JobExecution + func (j Job) NextExecutionStatus() ExecutionStatus + type JobExecution struct + CompletedAt time.Time + CreatedAt time.Time + ID uuid.UUID + Job Job + JobID uuid.UUID + Next time.Time + ScheduledAt time.Time + Status ExecutionStatus + type Repository struct + func NewRepository(c Config, db *sqlx.DB) *Repository + func (r *Repository) All() ([]Job, error) + func (r *Repository) AssembleInfrastructure() error + func (r *Repository) Begin() (*sqlx.Tx, error) + func (r *Repository) ClaimFor(workerID uuid.UUID) error + func (r *Repository) GetFor(workerID uuid.UUID) ([]Job, error) + func (r *Repository) GetOne(id uuid.UUID) (Job, error) + func (r *Repository) Heartbeat(workerID uuid.UUID) error + func (r *Repository) Store(job Job) error + func (r *Repository) StoreAll(jobs []Job) error + type Service struct + func Build(c Config) *Service + func (s *Service) AttachRouter(qa queueAction) + func (s *Service) Controller() *Controller + func (s *Service) Delete() + func (s *Service) RegisterJob(j Job) error + func (s *Service) Work(block bool)