resque

package module
v0.0.0-...-9c01273 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

resque

License Build Status Coverage Status Go Report Card

Project Stats

Resque client in Go.

Documentation

Index

Constants

View Source
const (
	// Queues name of the key for the set where Resque stores the currently available queues.
	Queues = "resque:queues"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConsumer

type BaseConsumer struct {
	*Worker
}

BaseConsumer Base struct for a Resque job consumer.

func NewConsumer

func NewConsumer() *BaseConsumer

NewConsumer creates a new consumer pointer.

func (*BaseConsumer) Consume

func (bc *BaseConsumer) Consume(args ...JobArgument) (interface{}, error)

Consume pass job class and arguments to the output.

func (*BaseConsumer) Subscribe

func (bc *BaseConsumer) Subscribe(wg *sync.WaitGroup, chanOut chan *Job, chanErr chan error, chanNext <-chan bool, chanExit <-chan bool)

Subscribe Go routine that retrieves Resque jobs from the worker Queue.

type BaseProducer

type BaseProducer struct {
	*Worker
}

BaseProducer Base struct for a job producer.

func NewProducer

func NewProducer() *BaseProducer

NewProducer creates a new producer pointer.

func (*BaseProducer) Produce

func (bp *BaseProducer) Produce(args ...JobArgument) *Job

Produce creates a Resque job message.

func (*BaseProducer) Publish

func (bp *BaseProducer) Publish(wg *sync.WaitGroup, chanIn <-chan *Job, chanErr chan error, chanExit <-chan bool)

Publish Go routine that sends Resque jobs to the worker Queue.

type Consumer

type Consumer interface {
	// Consume performs the Resque job work.
	Consume(args ...JobArgument) (interface{}, error)
	// Queue returns the queue.
	Queue() Queue
	// SetQueue assign a queue.
	SetQueue(q Queue)
}

Consumer interface Resque job consumers must implement.

type Job

type Job struct {
	Class string        `json:"class"`
	Args  []JobArgument `json:"args"`
}

Job represents a unit of work. Each job lives on a single queue and has an associated payload object.

The payload is a hash with two attributes: `class` and `args`. The `class` is the name of the class which should be used to run the job.

`Args` are an array of arguments which should be passed to the class's `perform` function.

func (Job) MarshalBinary

func (j Job) MarshalBinary() ([]byte, error)

MarshalBinary encodes itself into a binary format.

func (*Job) UnmarshalBinary

func (j *Job) UnmarshalBinary(b []byte) error

UnmarshalBinary decodes the binary representation into itself.

type JobArgument

type JobArgument interface{}

JobArgument represent a single argument.

type Producer

type Producer interface {
	// Produce creates a Resque job.
	Produce(args ...JobArgument) *Job
	// Queue returns the queue.
	Queue() Queue
	// SetQueue assign a queue.
	SetQueue(q Queue)
}

Producer interface Resque job producers must implement.

type Queue

type Queue interface {
	Consumer() Consumer
	Name() string
	Producer() Producer
	Receive() (*Job, error)
	Send(job *Job) error
}

Queue Queue interface.

type RedisQueue

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

RedisQueue a job RedisQueue.

func NewRedisQueue

func NewRedisQueue(name string, rc *redis.Client, timeout time.Duration, c Consumer, p Producer) (*RedisQueue, error)

NewRedisQueue initializes a RedisQueue struct and updates the set of available Resque queues.

func (*RedisQueue) Consumer

func (rq *RedisQueue) Consumer() Consumer

Consumer returns this Queue's consumer.

func (*RedisQueue) Name

func (rq *RedisQueue) Name() string

Name returns the Queue name.

func (*RedisQueue) Peek

func (rq *RedisQueue) Peek(start, stop int64) ([]Job, error)

Peek returns from the RedisQueue the jobs at position(s) [start, stop].

func (*RedisQueue) Producer

func (rq *RedisQueue) Producer() Producer

Producer returns this Queue's producer.

func (*RedisQueue) Receive

func (rq *RedisQueue) Receive() (*Job, error)

Receive gets a job from the RedisQueue.

func (*RedisQueue) Send

func (rq *RedisQueue) Send(job *Job) error

Send places a job to the RedisQueue.

func (*RedisQueue) Size

func (rq *RedisQueue) Size() (int64, error)

Size returns the number of jobs in the RedisQueue.

type Worker

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

Worker base struct to build consumers and producers.

func NewWorker

func NewWorker() *Worker

NewWorker creates a new worker pointer.

func (*Worker) Queue

func (w *Worker) Queue() Queue

Queue returns the queue.

func (*Worker) SetQueue

func (w *Worker) SetQueue(q Queue)

SetQueue assign a Queue.

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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