Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTaskQueue = fmt.Errorf("task queue error") ErrTaskQueueCapacity = fmt.Errorf("%w: capacity is exhausted", ErrTaskQueue) ErrTaskQueueUndefined = fmt.Errorf("%w: undefined", ErrTaskQueue) )
Functions ¶
This section is empty.
Types ¶
type Subject ¶
type Subject interface{}
Subject defines task subject used as key in map and requires comparable type
type Task ¶
type Task struct { Args []interface{} Idx uint8 Subject Subject // contains filtered or unexported fields }
Task defines queued task
type TaskQueue ¶
type TaskQueue struct {
// contains filtered or unexported fields
}
TaskQueue defines task queue
func NewTaskQueue ¶
func NewTaskQueue(opts ...TaskQueueOption) *TaskQueue
NewTaskQueue creates task queue
type TaskQueueOption ¶
type TaskQueueOption func(*TaskQueue)
TaskQueueOption defines task queue option
func WithAlarm ¶
func WithAlarm(d time.Duration, h Handler) TaskQueueOption
WithAlarm defines handler invoked on timeout after task start useful for log the long executed task
func WithCapacity ¶
func WithCapacity(c uint8) TaskQueueOption
WithCapacity defines capacity of task queue
func WithHandlers ¶
func WithHandlers(m map[Subject]Handler) TaskQueueOption
WithHandlers defines tasks
Click to show internal directories.
Click to hide internal directories.