disque

package
v0.0.0-...-1c692a2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2016 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disque

type Disque struct {
	// contains filtered or unexported fields
}

Disque connection type

func NewDisque

func NewDisque(servers []string, cycle int) *Disque

NewDisque instantiates a new Disque connection

func (*Disque) Ack

func (d *Disque) Ack(jobID string) (err error)

Ack will acknowledge receipt and processing of a message

func (*Disque) Close

func (d *Disque) Close()

Close the main connection maintained by this Disque instance

func (*Disque) Delete

func (d *Disque) Delete(jobID string) (err error)

Delete a job that was enqueued on the cluster

func (*Disque) Fetch

func (d *Disque) Fetch(queueName string, timeout time.Duration) (job *Job, err error)

Fetch a single job from a Disque queue.

func (*Disque) FetchMultiple

func (d *Disque) FetchMultiple(queueName string, count int, timeout time.Duration) (jobs []*Job, err error)

FetchMultiple will retrieve multiple jobs from a Disque queue.

func (*Disque) GetJobDetails

func (d *Disque) GetJobDetails(jobID string) (jobDetails *JobDetails, err error)

GetJobDetails will retrieve details for an existing job

func (*Disque) Initialize

func (d *Disque) Initialize() (err error)

Initialize the connection, including the exploration of nodes participating in the cluster.

func (*Disque) Nack

func (d *Disque) Nack(jobID string) (err error)

Nack instructs Disque to put back the job in the queue ASAP.

func (*Disque) Push

func (d *Disque) Push(queueName string, job string, timeout time.Duration) (jobID string, err error)

Push job onto a Disque queue with the default set of options

func (*Disque) PushWithOptions

func (d *Disque) PushWithOptions(queueName string, job string, timeout time.Duration, options map[string]string) (jobID string, err error)

PushWithOptions pushes a job onto a Disque queue with options given in the options map

ADDJOB queue_name job <ms-timeout>
  [REPLICATE <count>]
  [DELAY <sec>]
  [RETRY <sec>]
  [TTL <sec>]
  [MAXLEN <count>]
  [ASYNC]

Example:

options := make(map[string]string)
options["DELAY"] = 30
options["ASYNC"] = true
d.PushWithOptions("queue_name", "job", 1*time.Second, options)

func (*Disque) QueueLength

func (d *Disque) QueueLength(queueName string) (queueLength int, err error)

QueueLength will retrieve length of queue

type Job

type Job struct {
	QueueName            string
	JobID                string
	Message              string
	Nacks                int64
	AdditionalDeliveries int64
}

Job represents a Disque job

type JobDetails

type JobDetails struct {
	JobID                string
	QueueName            string
	State                string
	ReplicationFactor    int
	TTL                  time.Duration
	CreatedAt            time.Time
	Delay                time.Duration
	Retry                time.Duration
	Nacks                int64
	AdditionalDeliveries int64
	NodesDelivered       []string
	NodesConfirmed       []string
	NextRequeueWithin    time.Duration
	NextAwakeWithin      time.Duration
	Message              string
}

JobDetails contains details for a specific Disque job

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represents a pool of Disque connections

func NewPool

func NewPool(servers []string, cycle int, capacity int, maxCapacity int, idleTimeout time.Duration) (p *Pool)

NewPool creates a new pool of Disque connections. capacity is the number of active resources in the pool: there can be up to 'capacity' of these at a given time. maxCapacity specifies the extent to which the pool can be resized in the future through the SetCapacity function. You cannot resize the pool beyond maxCapacity. If a resource is unused beyond idleTimeout, it's discarded. An idleTimeout of 0 means that there is no timeout.

func (*Pool) Close

func (p *Pool) Close()

Close empties the pool calling Close on all its resources. You can call Close while there are outstanding resources. It waits for all resources to be returned (Put). After a Close, Get is not allowed.

func (*Pool) Get

func (p *Pool) Get(ctx context.Context) (conn *Disque, err error)

Get will return the next available resource. If capacity has not been reached, it will create a new one using the factory. Otherwise, it will wait until the supplied context expires.

func (*Pool) IsClosed

func (p *Pool) IsClosed() (closed bool)

IsClosed returns true if the resource pool is closed.

func (*Pool) Put

func (p *Pool) Put(conn *Disque)

Put will return a resource to the pool. For every successful Get, a corresponding Put is required. If you no longer need a resource, you will need to call Put(nil) instead of returning the closed resource. This will eventually cause a new resource to be created in its place.

func (*Pool) SetCapacity

func (p *Pool) SetCapacity(capacity int)

SetCapacity changes the capacity of the pool. You can use it to shrink or expand, but not beyond the max capacity. If the change requires the pool to be shrunk, SetCapacity waits till the necessary number of resources are returned to the pool. A SetCapacity of 0 is equivalent to closing the ResourcePool.

Jump to

Keyboard shortcuts

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