These are chat archives for dry-rb/chat

Feb 2018
Spencer Goh
Feb 22 2018 07:26

dry-transaction and wondering how one might facilitate long running tasks: eg.

step :preprocess_params
enqueue :generate_report # long running, handled by exector/threadpool or sidekiq
step :extract_and_parse_report_output
step :persist_to_storage
step :email_user_notification
  • I don't think there's a mechanism for callback and resumption of a next step.
  • some async/await fiber like dispatch and resumption of execution path would suit
  • in lieu of this, I'll have to
    • Split the transaction into 2 parts (before and after the async/long task)
    • have my long running task, on completion, callback/publish an event/message, then start

I like the idea that the transaction encapsulates and clearly declares the end to end steps, but I can't think of a clean way to handle the async or long running task.
I could wrap the whole transaction call in a thread/threadpool....

what's the best practice around this?

Nikita Shilnikov
Feb 22 2018 07:41
dry-transaction works with Result/Either which is a synchronous computation. If you wrap it with a thread pool you should be fine. There is also Task in dry-monads 1.0,0.beta1+ that can be run on a thread pool