Parent

DaemonKit::RuoteParticipants

Class that cleanly abstracts away the different remote participants in ruote and allows daemon writers to just worry about processing workitems without worrying over the transport mechanism or anything else...

Attributes

participants[R]

Public Class Methods

configure(&block) click to toggle source

Configure this daemon as a remote participant to ruote.

# File lib/daemon_kit/ruote_participants.rb, line 10
def configure(&block)
  instance.configure(&block)
end
instance() click to toggle source
# File lib/daemon_kit/ruote_participants.rb, line 22
def instance
  @instance ||= new
end
new() click to toggle source
# File lib/daemon_kit/ruote_participants.rb, line 35
def initialize
  @transports = []
  @participants = {}

  @configuration = Config.load('ruote')
end
run(&block) click to toggle source

Activate and run the remote participant code, calling the optional block for additional daemon logic.

# File lib/daemon_kit/ruote_participants.rb, line 16
def run(&block)
  instance.run(&block)
end

Public Instance Methods

configure(&block) click to toggle source

Yields self and configures the remote participants

# File lib/daemon_kit/ruote_participants.rb, line 43
def configure(&block)
  block.call( self )

  @transports.freeze
  @participants.freeze
end
register( *args ) click to toggle source

Register classes as pseudo-participants. Two styles of registration are supported:

register( Foo )
register( 'short', ShortParticipant )

The first format uses the class name (downcased and underscored) as the key for identifying the pseudo-participant, the second uses the the provided key.

Pseudo-participant classes are instantiated when registered, and the instances are re-used.

# File lib/daemon_kit/ruote_participants.rb, line 68
def register( *args )
  key, klass = if args.size == 1
    [ underscore( args.first.to_s ), args.first ]
  else
    [ args[0].to_s, args[1] ]
  end

  @participants[ key ] = klass.new
end
run(&block) click to toggle source

Run the participants

# File lib/daemon_kit/ruote_participants.rb, line 79
def run(&block)
  run_amqp! if @transports.include?( :amqp )
end
use( transport ) click to toggle source

Enable the use of a specific transport for workitems. Can be :amqp to use the AMQPParticipant/AMQPListener pair in ruote.

# File lib/daemon_kit/ruote_participants.rb, line 52
def use( transport )
  @transports << transport
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.