Documentation
¶
Index ¶
- Constants
- type BaseConsumer
- type BaseProducer
- type Consumer
- type Job
- type JobArgument
- type Producer
- type Queue
- type RedisQueue
- func (rq *RedisQueue) Consumer() Consumer
- func (rq *RedisQueue) Name() string
- func (rq *RedisQueue) Peek(start, stop int64) ([]Job, error)
- func (rq *RedisQueue) Producer() Producer
- func (rq *RedisQueue) Receive() (*Job, error)
- func (rq *RedisQueue) Send(job *Job) error
- func (rq *RedisQueue) Size() (int64, error)
- type Worker
Constants ¶
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 (*BaseConsumer) Consume ¶
func (bc *BaseConsumer) Consume(args ...JobArgument) (interface{}, error)
Consume pass job class and arguments to the output.
type BaseProducer ¶
type BaseProducer struct {
*Worker
}
BaseProducer Base struct for a job producer.
func (*BaseProducer) Produce ¶
func (bp *BaseProducer) Produce(args ...JobArgument) *Job
Produce creates a Resque job message.
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 ¶
MarshalBinary encodes itself into a binary format.
func (*Job) UnmarshalBinary ¶
UnmarshalBinary decodes the binary representation into itself.
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) 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.