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

Ensure that connecting method is synchronized #308

Merged
merged 1 commit into from
Feb 9, 2018

Commits on Feb 9, 2018

  1. Ensure that connecting to Rabbit is threadsafe

    When there are competing publisher threads, there is a chance that the
    publisher has not been initialized when Hutch is registered as
    connected. The following diagram should shed some light on the race
    condition:
    
    ```
            Thread 1                  Hutch                   Thread 2
            --------                  -------                 ---------
    t1      Hutch.publish()  --->  connected? (FALSE)
                               |-> open_connection!
    t2                             connected? (TRUE)  <--- Hutch.publish()
                                   @broker.publish()   |-> NoMethodError (@publisher)
    t3                         |-> declare_publisher!
            PUBLISHED        <-|   @broker.publish()
    ```
    
    Wrapping the `Hutch.connect` call should resolve this issue.
    cbarton committed Feb 9, 2018
    1 Configuration menu
    Copy the full SHA
    3789000 View commit details
    Browse the repository at this point in the history