Skip to content

Instantly share code, notes, and snippets.

@adrianpike
Created September 25, 2009 00:09
Show Gist options
  • Save adrianpike/193156 to your computer and use it in GitHub Desktop.
Save adrianpike/193156 to your computer and use it in GitHub Desktop.
Remoteling
Remoteling:
- redis server, everybody gets a private redis slice
- starling FIFO queue server, everybody can push & pop to it
- remoteling queue
- I can fire off processes that execute remotely from my app
- I can set up N resident processes running on the remoteling server
- Easy producer/consumer model
- Billing? Information gathering when new users show up? (see example A below)
Client Functions:
Remoteling.config({:key=>'foodebar'})
Remoteling.set('key','value')
Remoteling.get('key') # = value
### On the remoteling site, I can specify ways of getting my code to Remoteling & naming it
Remoteling.run('foobarProc', 'var1','var2') # returns maybe an ID for the remoteling process, false if it wasn't able to spawn it off
Remoteling.run('foobarProc', 'var1','var2', :synchronous=>true) # returns whatever the process returns, doesn't fork
# the following is a possibility
Remoteling.run(1,2) {|a,b|
data = 0
5.billion.times.do { data += a*b }
Cache.store('results_of_my_shindig', data)
}
sleep 10
Remoteling.get('results_of_my_shindog') # 15 billion
Remoteling.queue.push('item1')
Remoteling.queue.push('item2')
Remoteling.queue.pop # = item1
Remoteling.queue.pop # = item2
#### Example A ####
def User
after_create :get_twitter_followers
def twitter_followers
Remoteling.get('twitter_followers.'+self.twitter_username) || 'Calculating...'
end
private
def get_twitter_followers
Remoteling.run('get_twitter_followers',self.twitter_username)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment