[Backgroundrb-devel] periodic votes--threads or workers?

Matt Garland alias at pet-theory.com
Mon Sep 29 11:23:03 EDT 2008


I'm just getting started with BackgroundRB, but I'm not sure how to do  
what I need to do.

I have many chat rooms (Jabber) which are controlled or mediated by a  
Rails app. There are periodic elections carried out in these rooms.

Just this would be easy. I could set up a chron job in the  
configuration which gets all the chat rooms from Rails and calls  
chat.do_election on each (Chat is a model).

However, it is more complicated.  Often there is not enough members to  
vote: no quorum. Sometimes the chatters can "recall" a winner with an  
early vote. So each chat room is essentially it's own story, with its  
own chronology.

I know the signature of the election_worker class:

start_all_elections()# for create
trigger_election(chat_name)# tell Rails Model chat to do election with  
individual chat
stop_voting(chat_name)# Rails tells election_worker no quorum
start_voting(chat_name)# quorum is reached
skip_to_vote(chat_name)# vote is taken immediately, and clock reset,  
when Rails detects a recall

What I DO NOT know is how to deal with these multiple elections. Are  
these THREADS inside the election_worker class? If so, how would I set  
these up? (I'm new to threads).  Or are they multiple instances of  
election_worker? (Where then would I create multiple instances of the  
worker, since Rails has no "entry point"?)

Thanks, any help appreciated--


More information about the Backgroundrb-devel mailing list