Created
November 17, 2020 09:22
-
-
Save flash-gordon/9d5d8ee4bd22bffc0113108b1825ec42 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Operation | |
extend Dry::Effects::Handler.Defer | |
def run_long_something | |
with_defer do | |
transaction do | |
DoSomeBusinessStuff.new.call | |
end | |
end | |
end | |
end | |
class DoSomeBusinessStuff | |
include Dry::Effects.Defer | |
include Dry::Effects.Resolve(:logger, :async) | |
def call | |
... | |
later do | |
logger.debug('Dispatching to sidekiq') | |
async.(worker: 'SidekiqWorker', args: [1, 2, 3]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment