workingqueue

package
v0.1.3-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2016 License: GPL-3.0 Imports: 2 Imported by: 0

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) Close

func (w *WorkingQueue) Close()

Close stop all operations.

func (*WorkingQueue) MessageCounter

func (w *WorkingQueue) MessageCounter() int64

MessageCounter returns the number of produced messages.

func (*WorkingQueue) Run

func (w *WorkingQueue) Run() error

Run start dispatching queue.

func (*WorkingQueue) SendJob

func (w *WorkingQueue) SendJob(payload func(interface{}) error, arguments interface{})

SendJob enqueue a new job in the producer queue.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL