Created
April 20, 2017 12:23
-
-
Save alexandru-calinoiu/d01028d73ab4ea6ad28c48a9650e403d to your computer and use it in GitHub Desktop.
Async step adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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