Bill Walton wrote:
> If I understand your question correctly, you're looking for a 
> distributed
> Ruby library / plugin.  The standard library includes dRuby.
...
> WRT doing the work in the same process that handled the request, the 
> Rails
> architecture pretty much precludes that, at least as a 'best practice.'

Thanks Bill for the quick response.

Distributed Ruby is pretty heavyweight for what I have in mind.  It has 
a lot of moving parts.  I was thinking lightweight that would just allow 
me to time shift a few operations that can take a second or two so that 
the page is returned first and then those operations are then performed. 
(Example: queue an email.)  I'd like to have access to the full cached 
model when those post_processing operations run.

I poked around the source a little today and it seems feasible to patch 
in at the RailsHandler::process(request, response) level. That method 
could be aliased and replaced with a new process method:

alias :old_process :process

def process(request, response)
  old_process(request, response)
  post_process
end

where post_process was something like

within_timer_block do
  while task = @@background_tasks.shift
    task.call
  end
end

(The controllers would queue their slow operations onto 
@@background_tasks.)

The timers supervision is to preclude them taking too much time away 
from serving the next pages.  And it would be best to not allow more 
than one post_processing mongrel at a time for the same session (or 
possibly IP:port), lest a runaway Ajax loop consume all the mongrels for 
example.

Does this sound feasible?  Anyone know of some work along these lines 
already?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to