Documentation ¶
Index ¶
- Constants
- Variables
- type Log
- type Message
- type Red
- func (r *Red) Dequeue(ctx context.Context) (*Message, error)
- func (r *Red) Enqueue(ctx context.Context, key, value interface{}) error
- func (r Red) Error() error
- func (r Red) Lock(name string, opts ...redsync.Option) *redsync.Mutex
- func (r Red) Once(key string)
- func (r Red) RLock(name string, opts ...redsync.Option) *redsync.Mutex
- func (r Red) Repeat(key, recurrence string) error
- func (r Red) StartScheduling(handler func(task *Task), schedulers ...func())
- func (r Red) StopScheduling()
- func (r Red) Wait()
- type Scheduler
- func (s *Scheduler) Add(tasks ...*Task) *Scheduler
- func (s *Scheduler) DequeueTimeout(timeout time.Duration) *Scheduler
- func (s *Scheduler) EnqueueTimeout(timeout time.Duration) *Scheduler
- func (s *Scheduler) Every(interval time.Duration) *Scheduler
- func (s *Scheduler) Handle(fn func(task *Task))
- func (s *Scheduler) NewTask(id string) *Task
- func (s *Scheduler) Start()
- func (s *Scheduler) Stop()
- type Task
- type TaskSchedule
- type Worker
Constants ¶
const ( // DefaultSchedulerInterval is the default period between checking tasks to schedule DefaultSchedulerInterval = time.Millisecond // DefaultEnqueueTimeout is the default time allowed for queue write ops DefaultEnqueueTimeout = 100 * time.Millisecond // DefaultDequeueTimeout is the default time allowed for queue read ops DefaultDequeueTimeout = 100 * time.Millisecond )
const ( // DefaultInstances is the default number of simultaneous workers DefaultInstances = 1 // DefaultWorkerInterval is the default period between running batches of jobs DefaultWorkerInterval = time.Millisecond )
const (
// BatchSize the total number of errors and messages consumed before dropping occurs
BatchSize = 1024
)
Variables ¶
var ( // ErrNoMessages is an error returned when a request is made but no messages are available ErrNoMessages = trail.NewErrorBadRequest("no messages currently available") )
Functions ¶
This section is empty.
Types ¶
type Log ¶ added in v0.0.10
type Log struct {
// contains filtered or unexported fields
}
Log instance with quiet support
type Message ¶
type Message struct { Id string `json:"id"` Value []byte `json:"value"` // contains filtered or unexported fields }
Message is a single instance of a message within the queue.
type Red ¶
Red is an instance of the exclusive message queue.
func (Red) StartScheduling ¶ added in v0.0.17
StartScheduling tasks
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is an instance of a persistent background scheduler
func NewScheduler ¶
NewScheduler creates a scheduler instance.
func (*Scheduler) DequeueTimeout ¶
DequeueTimeout sets the maximum time to wait for remove items from queue.
func (*Scheduler) EnqueueTimeout ¶
EnqueueTimeout sets the maximum time to wait for adding items to queue.
type Task ¶
type Task struct { Id string `json:"id"` Schedule TaskSchedule `json:"schedule"` *redsync.Mutex }
Task is an instance of a thing to be scheduled.
func (*Task) CanSchedule ¶
CanSchedule determines if the task can be scheduled at given time.
func (*Task) IsComplete ¶
IsComplete checks if the tasks can no longer be scheduled.
func (*Task) MarkScheduled ¶
MarkScheduled marks the task as scheduled.
func (*Task) Occurrences ¶
Occurrences gets the number of times the task has been scheduled.
func (*Task) SetRecurrence ¶
SetRecurrence sets a new recurrence rule based on rfc 5545
type TaskSchedule ¶
type TaskSchedule struct { Recurrence string `json:"recurrence"` Count int `json:"count"` UpdatedAt time.Time `json:"updatedAt"` sync.RWMutex }
TaskSchedule is the schedule for when the task is to occur.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is an instance of a background worker.
func NewQWorker ¶ added in v0.0.17
NewQWorker creates a new worker instance with quiet mode enabled.
func (*Worker) AddJobs ¶ added in v0.0.17
func (w *Worker) AddJobs(jobs ...func())
AddJobs adds jobs to the worker
func (*Worker) Concurrent ¶
Concurrent sets the number of simultaneous instances to process tasks.