Module: Ruote::Resque

Defined in:
lib/ruote/resque.rb,
lib/ruote/resque/job.rb,
lib/ruote/resque/client.rb,
lib/ruote/resque/version.rb,
lib/ruote/resque/receiver.rb,
lib/ruote/resque/reply_job.rb,
lib/ruote/resque/participant_registrar.rb

Overview

Ruote::Resque allows a Ruote engine to delegates the work of it's participants to Resque workers.

Common use cases include:

  • You run a lot of jobs and need the reliability of Resque to process your jobs
  • You have a Resque system you need to integrate with
  • You want a separation of concerns between process orchestration and actual execution

See the README for usage instructions

Defined Under Namespace

Modules: Job, ReplyJob Classes: Configuration, InvalidJob, InvalidWorkitem, Participant, ParticipantRegistrar, Receiver

Constant Summary collapse

VERSION =
'0.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the current Configuration



30
31
32
# File 'lib/ruote/resque/client.rb', line 30

def configuration
  @configuration
end

Class Method Details

.configure {|Configuration| ... } ⇒ void

This method returns an undefined value.

This method allows you to customize the ruote-resque configuration.

Yields:

See Also:



49
50
51
52
# File 'lib/ruote/resque/client.rb', line 49

def configure
  self.configuration ||= Ruote::Resque::Configuration.new
  yield(configuration) if block_given?
end

.loggerLogger

Returns the logger to be used inside ruote-resque.

Returns:

  • (Logger)

    the logger to be used inside ruote-resque



41
42
43
# File 'lib/ruote/resque/client.rb', line 41

def logger
  configuration.logger
end

.register(dashboard, &block) ⇒ void

This method returns an undefined value.

Registers resque participants using a DSL.

Examples:

Using the dsl

Ruote::Resque.register dashboard do
  be_awesome MyAwesomeJob, :my_queue
  be_really_awesome 'MyReallyAwesomeJob', :my_queue, :forget => true
end

Using the participant method

Ruote::Resque.register dashboard do
  participant /be_.*/, BeSomething, :my_queue
end

Parameters:

  • dashboard (Ruote::Dashboard)

    the ruote dashboard



34
35
36
37
# File 'lib/ruote/resque.rb', line 34

def self.register(dashboard, &block)
  registrar = Ruote::Resque::ParticipantRegistrar.new(dashboard)
  registrar.instance_eval(&block)
end

.reply(*args) ⇒ Object

Enqueues a ReplyJob with the given arguments.

Examples:

Ruote::Resque.reply(workitem)

Returns:

  • true if the job was queued, nil if the job was rejected by a before_enqueue hook.



36
37
38
# File 'lib/ruote/resque/client.rb', line 36

def reply(*args)
  ::Resque.enqueue(Ruote::Resque::ReplyJob, *args)
end