Skip to content

Instantly share code, notes, and snippets.

@alexandru-calinoiu
Created April 20, 2017 12:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandru-calinoiu/d01028d73ab4ea6ad28c48a9650e403d to your computer and use it in GitHub Desktop.
Save alexandru-calinoiu/d01028d73ab4ea6ad28c48a9650e403d to your computer and use it in GitHub Desktop.
Async step adapter
class Enqueue
include Dry::Monads::Either::Mixin
include IngestService::Import['enqueue']
def call(step, input, *args)
enqueue.call(step.operation_name, input, args)
Right(input)
end
end
register :enqueue, Enqueue.new
module Service
class Enqueue
class Job
include Sidekiq::Worker
def perform(identifier, *args)
operation = Container[identifier]
operation.call_from_queue(args)
end
end
def call(identifier, *args)
operation = Container[identifier]
Job.perform_async(identifier, *operation.to_queue(*args))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment