Jeff, thanks a lot.
Just one thing though: if I do this, does it mean I am taking the
session data "out of" ActiveRecord? I was thinking that by only
passing the session ID and by letting the worker retrieve the record
in the DB, consistency would be guaranteed by ActiveRecord. But maybe
I am getting this wrong?
Indeed, I need to do quite a lot of things on this session data in the
background: several workers are going to work on it at the same time,
and one of them will have to create some threads… I am struggling to
understand whether there will be concurrency risks - therefore I
thought I would try and rely on ActiveRecord as much as possible.
Here is in pseudo-code what I had in mind:
### in ./app/workers/foo_worker.rb
class FooWorker < Workling::Base
def bar(options)
session = Session.find(options[:session_id])
# do something with session.data hash ...
end
end
### in ./app/workers/foo_worker2.rb
class FooWorker2 < Workling::Base
def bar(options)
for i in 1..10
Thread.new(options[:session_id]) { |session_id| retrieve
session data and do stuff }
end
end
end
### in some_meth in ./app/controllers/some_controller.rb
...
FooWorker.asynch_bar(:session_id =>session.id)
FooWorker2.asynch_bar(:session_id =>session.id)
...
Am I getting it wrong?
Thanks a lot!
Pierre
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.