On Thu, Jun 03, 2010 at 04:53:49PM +0200, Asier wrote:
> El 03/06/2010 14:12, John Mettraux escribió:
> >
> > http://github.com/kennethkalmer/ruote-amqp/
> > http://github.com/jmettraux/ruote-beanstalk/
> > http://github.com/tosch/ruote-jig/
>
> After looking these 3 alternatives (i didn't know about beanstalkd)
> the most easy to implement looks to be ruote-beanstalk
>
> Where (or better, how) can I add some participants to ruote kit?
>
> I don't know where to place them: config.ru? configuration.rb?
>
> I've made some experiments with ruote-jig and surely my Ruby skills
> are very low because I broke ruote-kit trying to add participants.
Hello Asier,
config.ru looks like a good place.
---8<---
# (...)
require 'asier/participants/totalizer'
# Chance to configure ruote-kit
RuoteKit.configure do |config|
# storage mode
#config.mode = :transient
# run a worker
config.run_worker = true
config.register do
# With this rackup I bundle as catchall, making it easy to experiment
participant 'totalizer', Asier::Participants::Totalizer
catchall
end
end
# (...)
--->8---
with
---8<---
module Asier
module Participants
class Totalizer
include Ruote::LocalParticipant
def initialize (opts)
@opts = opts
end
def consume (workitem)
workitem.fields['total'] = workitem.fields['items'].inject(0) { |t, item|
t + item.price * item.count
}
reply_to_engine(workitem)
end
end
end
end
--->8---
I hope this will help, best regards,
--
John Mettraux - http://jmettraux.wordpress.com
--
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en