Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on_async_exit for subscriber called when async publisher is done #54

Open
criskim opened this issue Apr 12, 2016 · 4 comments
Open

on_async_exit for subscriber called when async publisher is done #54

criskim opened this issue Apr 12, 2016 · 4 comments
Assignees
Labels

Comments

@criskim
Copy link

criskim commented Apr 12, 2016

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?

@mhuggins
Copy link
Contributor

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

@mhuggins
Copy link
Contributor

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

@criskim
Copy link
Author

criskim commented Apr 12, 2016

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?

@mhuggins
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants