Skip to content

Commit

Permalink
Add Resque async handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon de Andres committed Oct 3, 2014
1 parent 9e545bd commit 5332536
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/rollbar/delay/resque.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'resque'

module Rollbar
module Delay
class Resque
def self.call(payload)
new.call(payload)
end

def call(payload)
::Resque.enqueue(Job, payload)
end

class Job
def self.queue; 'default'; end

def self.perform(payload)
new.perform(payload)
end

def perform(payload)
Rollbar.process_payload(payload)
end
end
end
end
end
1 change: 1 addition & 0 deletions rollbar.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'sidekiq', '>= 2.13.0' if RUBY_VERSION != '1.8.7'
gem.add_development_dependency 'genspec', '>= 0.2.7'
gem.add_development_dependency 'sinatra'
gem.add_development_dependency 'resque'
end
21 changes: 21 additions & 0 deletions spec/rollbar/delay/resque_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'
require 'rollbar/delay/resque'

describe Rollbar::Delay::Resque do
describe '.call' do
let(:payload) do
{ :key => 'value' }
end

before do
allow(Resque).to receive(:inline?).and_return(true)
end

it 'process the payload' do
loaded_hash = MultiJson.load(MultiJson.dump(payload))

expect(Rollbar).to receive(:process_payload).with(loaded_hash)
described_class.call(payload)
end
end
end

0 comments on commit 5332536

Please sign in to comment.