Documentation ¶
Overview ¶
Package workingqueue implement a concurrent working queue able to process any passed payload (having a standard function signature) managing the maximum number of active workers. This is intended to be used on high volumes of processing to manage efficiently workloads without doing auto Ddos creating always new goroutines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicCounter ¶
type AtomicCounter struct {
// contains filtered or unexported fields
}
AtomicCounter concurrent safe counter.
func (*AtomicCounter) Add ¶
func (c *AtomicCounter) Add(x int64)
Add increment of quantity x the counter.
func (*AtomicCounter) Value ¶
func (c *AtomicCounter) Value() int64
Value returns the actual counter value.
type WorkingQueue ¶
type WorkingQueue struct {
// contains filtered or unexported fields
}
WorkingQueue base struct used to represent the working queue.
func NewWorkingQueue ¶
func NewWorkingQueue(workerSize int, queueSize int, errorc chan error) *WorkingQueue
NewWorkingQueue creates a new wq initialising all internal properties.
func (*WorkingQueue) MessageCounter ¶
func (w *WorkingQueue) MessageCounter() int64
MessageCounter returns the number of produced messages.
func (*WorkingQueue) SendJob ¶
func (w *WorkingQueue) SendJob(payload func(interface{}) error, arguments interface{})
SendJob enqueue a new job in the producer queue.