queue

package
v0.0.0-...-cb4208f Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// deadlineSoonDelay defines a period to sleep between receiving
	// DEADLINE_SOON in response to reserve, and re-attempting the reserve.
	DeadlineSoonDelay = 1 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BeanstalkdConnectionPool

type BeanstalkdConnectionPool struct {
	Queues map[string]*beanstalk.TubeSet
	// contains filtered or unexported fields
}

BeanstalkdConnectionPool ...

func NewBeanstalkdConnectionPool

func NewBeanstalkdConnectionPool(address string) *BeanstalkdConnectionPool

NewBeanstalkdConnectionPool ...

func (*BeanstalkdConnectionPool) Address

func (bs *BeanstalkdConnectionPool) Address() string

Address ...

func (*BeanstalkdConnectionPool) CheckConnection

func (bs *BeanstalkdConnectionPool) CheckConnection() bool

CheckConnection ...

func (*BeanstalkdConnectionPool) ConsumeMessage

func (bs *BeanstalkdConnectionPool) ConsumeMessage(queueName string, timeout time.Duration) (job *Job, err error)

ConsumeMessage reserve-with-timeout until there's a job or something panic-worthy. Handles beanstalk.ErrTimeout by retrying immediately. Handles beanstalk.ErrDeadline by sleeping DeadlineSoonDelay before retry. panics for other errors.

func (*BeanstalkdConnectionPool) CountMessages

func (bs *BeanstalkdConnectionPool) CountMessages(queueName string) (uint64, error)

CountMessages return total number of ready-items in the queue

func (*BeanstalkdConnectionPool) DeleteMessage

func (bs *BeanstalkdConnectionPool) DeleteMessage(queueName string, job *Job) error

DeleteMessage ...

func (*BeanstalkdConnectionPool) GetQueue

func (bs *BeanstalkdConnectionPool) GetQueue(queueName string) *beanstalk.TubeSet

GetQueue ...

func (*BeanstalkdConnectionPool) GiveupMessage

func (bs *BeanstalkdConnectionPool) GiveupMessage(queueName string, job *Job) error

GiveupMessage ...

func (*BeanstalkdConnectionPool) ListQueues

func (bs *BeanstalkdConnectionPool) ListQueues() (queueNames []string, err error)

ListQueues Returns a list of all queue names.

func (*BeanstalkdConnectionPool) ReturnMessage

func (bs *BeanstalkdConnectionPool) ReturnMessage(queueName string, job *Job, delay time.Duration) error

ReturnMessage ...

type InterfaceQueueConnectionPool

type InterfaceQueueConnectionPool interface {

	// Returns a list of all queue names.
	ListQueues() (queueNames []string, err error)

	// Count the number of messages in queue. This can be a approximately number.
	CountMessages(queueName string) (uint64, error)

	// ConsumeMessage
	ConsumeMessage(queueName string, timeout time.Duration) (job *Job, err error)

	// DeleteMessage
	DeleteMessage(queueName string, job *Job) error

	// ReturnMessage
	ReturnMessage(queueName string, job *Job, delay time.Duration) error

	// GiveupMessage
	GiveupMessage(queueName string, job *Job) error
}

InterfaceQueueConnectionPool ...

type Job

type Job struct {
	ID        uint64
	Payload   interface{}
	QueueName string

	NumTimeOuts uint64        // number of times the job has been reserved and timeout
	NumReturns  uint64        // number of times the job has been returned (release) to the queue
	TimeLeft    time.Duration // remain time for processing
}

Job Structure that wraps Jobs information

Jump to

Keyboard shortcuts

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