37. Human trigger - console
$ script/console production
Loading production environment
(Rails 2.0.2)
>> Photo.destroy_all
38. No trigger?
- Send email in 2 hours
- Sync data at 3:00am PST
- Notify admin when disk is 90% full
- Expire sessions that are inactive
- Archive records that exceed quota
45. Zencoder
User
Video Sharing
Website
Data Storage
(Amazon S3)
Zencoder
Manager
Worker Worker
Worker Worker
46.
47. class Photo < ActiveRecord::Base
after_create :background_s3_upload
def background_s3_upload
Bj.submit quot;./script/runner ./jobs/send_to_s3.rb #{self.id}quot;
end
end
86. require 'memcache'
starling = MemCache.new('192.168.1.1:22122')
# Put messages onto a queue:
starling.set('my_queue', 12345)
# Get message from the queue:
starling.get('my_queue')
97. BackgroundDRb
class BillingWorker < BackgrounDRb::MetaWorker
set_worker_name :billing_worker
def create(args = nil)
# this method is called when worker is loaded for the first time
end
def charge_customer(customer_id = nil)
logger.info 'charging customer now'
end
end
MiddleMan.worker(:billing_worker).charge_customer(current_customer.id)