Resque Intro

Resque Intro

Done @ Apero Ruby Lille

Fd6c3e14f1aafe3ce6e9084291096df6?s=128

Robin Komiwes

October 31, 2012
Tweet

Transcript

  1. 4.

    Background jobs JSON pending jobs in Redis Ruby multiples Queues

    Persistents Workers Classes that respond to `perform`
  2. 5.

    # lib/resque/archive.rb class Archive @queue = :file_serve def self.perform(repo_id, branch

    = 'master') repo = Repository.find(repo_id) repo.create_archive(branch) end end # app/models/repository.rb class Repository def async_create_archive(branch) Resque.enqueue(Archive, self.id, branch) end end
  3. 7.

    Steve Klabnik "Yet Another GitHub Project They've Open Sourced and

    Then Abandoned." But Resque is super awesome [...] http://blog.steveklabnik.com/posts/2012-09-22-resque--let-s-do-this
  4. 11.

    daily_digest: cron: "0 */24 * * *" class: Digest description:

    "The one time a day activity digest" args: [1] bidaily_digest: cron: "0 */12 * * *" class: Digest description: "The two time a day activity digest" args: [2] instant_digest: cron: "*/5 * * * *" class: Digest description: "Send each 5 minuts a digest" args: [3]
  5. 12.

    module UploadImageToCdn extend Resque::Plugins::ExponentialBackoff @queue = :cdn_upload @backoff_strategy = [0,

    0, 0, 0.5, 1, 2, 5, 10] def perform( image_id ) # ... end extend self end
  6. 14.

    require 'resque/plugins/lock' module SummarizeProject extend Resque::Plugins::Lock @queue = :summarize_project def

    perform( gallery_id ) gallery = Gallery.find( gallery_id ) gallery.summarize end extend self end
  7. 16.

    Run | production ★ Configure Upstart to auto-restart workers when

    they are down. ★ Capistrano deploy hook to shutdown running workers. after "deploy:create_symlink", "deploy:stop_resque"