Skip to content

Instantly share code, notes, and snippets.

@ryanlecompte
Created February 5, 2012 04:12
Show Gist options
  • Select an option

  • Save ryanlecompte/1742620 to your computer and use it in GitHub Desktop.

Select an option

Save ryanlecompte/1742620 to your computer and use it in GitHub Desktop.
alternative to invoking middleware in sidekiq
def process(msg)
klass = constantize(msg['class'])
invoke_chain(klass.new, msg)
@boss.processor_done!(current_actor)
end
def invoke_chain(worker, msg)
chain = Sidekiq::Middleware::Chain.retrieve.dup
traverse_chain = lambda do
if chain.empty?
worker.perform(*msg['args'])
else
chain.shift.call(worker, msg, &traverse_chain)
end
end
traverse_chain.call
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment