Skip to content

Instantly share code, notes, and snippets.

@flash-gordon
Created November 17, 2020 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flash-gordon/9d5d8ee4bd22bffc0113108b1825ec42 to your computer and use it in GitHub Desktop.
Save flash-gordon/9d5d8ee4bd22bffc0113108b1825ec42 to your computer and use it in GitHub Desktop.
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