Add girl_friday to your application's Gemfile:
Then you declare your application's required background processors in
EMAIL_QUEUE = GirlFriday::WorkQueue.new(:user_email) do |msg| UserMailer.registration_email(msg).deliver end IMAGE_QUEUE = GirlFriday::WorkQueue.new(:image_crawler) do |msg| ImageCrawler.process(msg) end
In your controller action or model, you can call push(msg):
EMAIL_QUEUE.push(:email => @user.email, :name => @user.name)
The msg parameter to push is just a Hash whose contents are completely up to you.
Please see the girl_friday wiki for more detail and advanced options and tuning. You'll find details on queue persistence with Redis, usage with Heroku, implementing clean shutdown, querying runtime metrics and so much more!
The term Man Friday has become an idiom, still in mainstream usage, to describe an especially faithful servant or one's best servant or right-hand man. The female equivalent is Girl Friday. The title of the movie His Girl Friday alludes to it and may have popularized it.
Site design by Chad Seeger ( @cs44 )