circuitry icon indicating copy to clipboard operation
circuitry copied to clipboard

on_async_exit for subscriber called when async publisher is done

Open criskim opened this issue 9 years ago • 4 comments

Hi there,

Awesome gem. Really been enjoying working with it.

Not sure if this is the intended behavior but looking at master/lib/circuitry/processor.rb it seems like the on_exit method is set such that the subscriber's on_async_exit method is called regardless of the publisher or subscriber calling the asynchronous method.

Same seems to be the case for logger and error handler. Am I just misunderstanding something?

criskim avatar Apr 12 '16 19:04 criskim

The on_exit method is only ever called from within a thread or fork, i.e.:

mhuggins avatar Apr 12 '16 20:04 mhuggins

Also worth mentioning that logger and error_handler are just methods referencing the config. They're not being called unless they're needed.

mhuggins avatar Apr 12 '16 20:04 mhuggins

So I ran this example:

Circuitry.subscriber_config do |c|
  ...
  c.async_strategy = :thread
  c.on_async_exit = proc do
    Rails.logger.info "subscriber done"
  end
  ...
end

Circuitry.publisher_config do |c|
  ...
  c.async_strategy = :thread
  c.on_async_exit = proc do
    Rails.logger.info "publisher done"
  end
  ...
end

Circuitry.publish('topic', 'message', async: true, timeout: 20)

My expectation was that it would log "publisher done" but instead I received "subscriber done". Is that the intended behavior?

criskim avatar Apr 12 '16 20:04 criskim

Ahh, I follow what you're saying now. That is a legit bug. Thank you for the report!

mhuggins avatar Apr 12 '16 20:04 mhuggins