Documentation ¶
Index ¶
- Constants
- func WithAdjustPriority(adjustment func() int) workOption
- func WithName(name string) workOption
- func WithPriority(priority int) workOption
- type Queue
- func (w *Queue) Break()
- func (w *Queue) Dequeue(id uuid.UUID) error
- func (w *Queue) Enqueue(workToDo Work, options ...workOption) uuid.UUID
- func (w *Queue) Errors() chan error
- func (w *Queue) ResizeQueueLength(length int)
- func (w *Queue) SetPriority(id uuid.UUID, priority int) error
- func (w *Queue) Stop()
- func (w *Queue) WorkItems() []*QueuedWork
- type QueuedWork
- type Work
- type WorkQueueOption
Constants ¶
const ( IN_QUEUE workState = iota IN_PROGRESS )
work states
Variables ¶
This section is empty.
Functions ¶
func WithAdjustPriority ¶ added in v0.1.1
func WithAdjustPriority(adjustment func() int) workOption
WithAdjustPriority adds an adjustment priorty function to the workItem such that it's priority can be dynamically adjusted in queue
func WithName ¶ added in v0.2.0
func WithName(name string) workOption
WithName adds a name for the work (for reporting)
func WithPriority ¶
func WithPriority(priority int) workOption
WithPriority sets the priority of the work to be done. Lower number is higher priority.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue allow work to be queued up and worked on in a set number of go routines
func NewQueue ¶
func NewQueue(options ...WorkQueueOption) *Queue
NewQueue returns a reference to an initialized Queue
func (*Queue) Break ¶
func (w *Queue) Break()
Break stops the queue form accepting any work and any work in queue is skipped
func (*Queue) Dequeue ¶ added in v0.2.0
Dequeue removes from the queue the work item with the specified id. If the work item is in process, then an error is returned.
func (*Queue) ResizeQueueLength ¶ added in v0.2.0
ResizeQueueLength adjusts the size of the queue
func (*Queue) SetPriority ¶ added in v0.2.1
SetPriority changes the priority of the queued work item with the uuid.
func (*Queue) WorkItems ¶ added in v0.2.0
func (w *Queue) WorkItems() []*QueuedWork
WorkItems returns the current state of all queued work items
type QueuedWork ¶ added in v0.2.0
type QueuedWork struct {
// contains filtered or unexported fields
}
func (*QueuedWork) Id ¶ added in v0.2.0
func (w *QueuedWork) Id() string
func (*QueuedWork) Name ¶ added in v0.2.0
func (w *QueuedWork) Name() string
func (*QueuedWork) Priority ¶ added in v0.2.0
func (w *QueuedWork) Priority() int
func (*QueuedWork) State ¶ added in v0.2.0
func (w *QueuedWork) State() string
type WorkQueueOption ¶
type WorkQueueOption func(*Queue)
func WithQueueLength ¶
func WithQueueLength(queueLength int) WorkQueueOption
WithQueueLength sets the number of functions that can be queued up before routines queueing are blocked
func WithWorkers ¶
func WithWorkers(workerCount int) WorkQueueOption
WithWorkers sets the number of go routines working on the workChan