Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request DynamoMTL#79 from jkelleyj/resque
Browse files Browse the repository at this point in the history
Add Resque worker
  • Loading branch information
braidn authored Nov 3, 2016
2 parents bc3dae9 + 2833cfd commit 14c540f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/spree/chimpy/workers/resque.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Spree::Chimpy
module Workers
class Resque
delegate :log, to: Spree::Chimpy

QUEUE = :default
@queue = QUEUE

def self.perform(payload)
Spree::Chimpy.perform(payload.with_indifferent_access)
rescue Excon::Errors::Timeout, Excon::Errors::SocketError
log "Mailchimp connection timeout reached, closing"
end
end
end
end
2 changes: 2 additions & 0 deletions lib/spree_chimpy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def handle_event(event, payload = {})
run_at: Proc.new { 4.minutes.from_now })
when defined?(::Sidekiq)
Spree::Chimpy::Workers::Sidekiq.perform_in(4.minutes, payload.except(:object))
when defined?(::Resque)
::Resque.enqueue(Spree::Chimpy::Workers::Resque, payload.except(:object))
else
perform(payload)
end
Expand Down

0 comments on commit 14c540f

Please sign in to comment.