[ANN] BackgrounDRb New release

Howdy Folks-

I'm happy to announce a new release of BackgrounDRb! I have added

quite a few new features and included some nice patches from folks on
the list.

$ script/plugin install svn://rubyforge.org//var/svn/backgroundrb

All of the code now stays within the plugin and the start and stop

scripts are now just stubs. This makes it easier to tweak or figure
out how it works. The backgroundrb.rb file in the root of the plugin
dir is the drb server part of MiddleMan and the pluginroot/lib/
backgroundrb.rb file is the rails client side MiddleMan.

One of the new things is much better threading job control. This is

mostly invisible to you as a user of the plugin but it makes the
whole system a lot more sturdy. It gives your worker objects the
chance to clean up after themselves when they get deleted instead of
just getting the kill brick dropped on them :wink: Thanks to David
Lemstra for the job management code!

The other big new feature is a built in timer and a time to live

argument for workers and caches. This allows you to set how long a
worker or a cache survives before it gets reaped. The :ttl param
defaults to 30 minutes for worker classes and 10 minutes for cached
objects. If you don;t specify the :ttl param then thats how long your
stuff will last. If you want longer or shorter ttl’s then
specify :ttl in seconds like this:

#worker
session[:job_key] = MiddleMan.new_worker(:class => :foo_worker,

       :args => "Bar",

       :ttl => 300) # 300 seconds == 5 minutes

#caching

#fill_cache, expire in 5 minutes
@posts = Post.find(:all, :include => :comments)
MiddleMan.cache_as(:post_cache, 300, @posts)
#OR
@posts = MiddleMan.cache_as :post_cache, 300 do
Post.find(:all, :include => :comments)
end

#retrieve_cache
@posts = MiddleMan.cache_get :post_cache do
Post.find(:all, :include => :comments)
end

By default the timer_sleep is set to 60 seconds. This means that the

timer will wakeup every 60 seconds and delete caches and worker that
are past their time to live. You can change this in the config file
if you want it to run faster or slower.

All your worker classes should now inherit from BackgrounDRb::Rails

so they get all the good new thread management features. If you are
already using the plugin you should delete the plugin from your rails
app and reinstall it. You should also delete the script/backgroundrb
directory and the config/backgroundrb.yml file. Then run:

to install the new code.

$ rake backgroundrb:setup

Your workers should not need to change as long as they inherit from
BackgrounDRb::Rails. Please test this and give me feedback if you are
using it. I would also like to start collecting worker classes or at
least hear what folks are using this plugin for.

*Home page: http://backgroundrb.rubyforge.org
*svn repo: svn://rubyforge.org//var/svn/backgroundrb
*Mailing list: http://rubyforge.org/mailman/listinfo/backgroundrb-devel

Thanks
-Ezra

How about jobs that I would like to run forever?

I collect newsfeeds from various sites in background and would like to
run
them forever!!

In fact…i was doing this, but what to do now?
So…when a job gets deleted after 30 minutes…does it also deletes the
session key? If not…then we won’t be able to detect within our rails
app,
if the client has died!!

Hi,

I would like to do something simple yet I’m confused.

Lets say I have a table with 2 fields: rank, updated_at.

I would like to show all records matching this condition:

Rank = rank - (Time.now - Updated_at.to_time)

As you can see this is supposed to be a calculation on the field.

How do I write a query to show this?

I’ve tried with_scope, and regular find but did not succeed.

Please advice

Thanks

Adi

On Jul 3, 2006, at 7:04 AM, hemant wrote:

On 7/2/06, Ezra Z. [email protected] wrote:
Howdy Folks-

    I'm happy to announce a new release of BackgrounDRb! I have  

added
quite a few new features and included some nice patches from folks on
the list.

$ script/plugin install svn://rubyforge.org//var/svn/backgroundrb

Hemant-

Thats a good point. I will add an option to allow for 'immortal'

workers. Does this syntax look good to you?

session[:job_key] = MiddleMan.new_worker(:class => :long_worker,

      :args => 'whatever',

      :ttl => :immortal)

I will see what the best way to add this is and get another release

out today.

Thanks
-Ezra

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs