Class: Ruote::Beanstalk::Receiver

Inherits:
Receiver
  • Object
show all
Defined in:
lib/ruote/beanstalk/receiver.rb

Overview

Whereas ParticipantProxy emits workitems(and cancelitems) to a Beanstalk queue, the receiver watches a Beanstalk queue/tube.

An example initialization :

Ruote::Beanstalk::Receiver.new(
  engine, '127.0.0.1:11300', :tube => 'out')

workitem format

ParticipantProxy and Receiver share the same format :3

[ 'workitem', workitem_as_a_hash ]
  # or
[ 'error', error_details_as_a_string ]

extending this receiver

Feel free to extend this class and override the listen or the process method.

:tube

Indicates to the receiver which beanstalk tube it should listen to.

Ruote::Beanstalk::Receiver.new(
  engine, '127.0.0.1:11300', :tube => 'out')

Instance Method Summary collapse

Constructor Details

#initialize(cwes, beanstalk, options = {}) ⇒ Receiver

cwes = context, worker, engine or storage



82
83
84
85
86
87
88
89
# File 'lib/ruote/beanstalk/receiver.rb', line 82

def initialize(cwes, beanstalk, options={})

  super(cwes, options)

  Thread.new do
    listen(beanstalk, options['tube'] || options[:tube] || 'default')
  end
end