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

Rework how the client connects to brokers. #10

Merged
merged 4 commits into from
Aug 14, 2013

Commits on Aug 14, 2013

  1. Rework how the client connects to brokers.

    Fixes #9.
    
    This ended up being more complicated than I had hoped and touched several
    different areas. TL;DR is that we now connect to the other brokers in the
    cluster asynchronously. Errors connecting only show up when somebody tries to
    use that broker.
    
    This is better than the old behaviour since it means that if some brokers in a
    cluster go down but the topics we care about are still available, we just keep
    going instead of blowing up for no reason.
    
    The complicated part is that simply calling `go broker.Connect()` doesn't do
    what we want, so I had to write a `broker.AsyncConnect()`. The problem occurs if
    you've got code like this:
        go broker.Connect()
        // do some stuff
        broker.SendSomeMessage()
    What can happen is that SendSomeMessage can be run before the Connect()
    goroutine ever gets scheduled, in which case SendSomeMessage will simply return
    NotConnected. The desired behaviour is that SendSomeMessage waits for Connect()
    to finish, which means Connect() has to *synchronously* take the broker lock
    before it launches the asynchronous connect call. Lots of fun.
    
    And bonus change in this commit: rather than special-casing leader == -1 in
    `client.cachedLeader` and adding a big long comment to the LEADER_NOT_AVAILABLE
    case explaining the fallthrough statement, just delete that partition from the
    hash. So much easier to follow, I must have been on crack when I wrote the old
    way.
    eapache committed Aug 14, 2013
    Configuration menu
    Copy the full SHA
    a0e96da View commit details
    Browse the repository at this point in the history
  2. No need for a separate err variable, thanks Burke

    Evan Huus committed Aug 14, 2013
    Configuration menu
    Copy the full SHA
    46629e3 View commit details
    Browse the repository at this point in the history
  3. Match the golang database pattern

    Replaces Connect and AsyncConnect with Open and Connected
    Evan Huus committed Aug 14, 2013
    Configuration menu
    Copy the full SHA
    934c568 View commit details
    Browse the repository at this point in the history
  4. tweak broker example

    Evan Huus committed Aug 14, 2013
    Configuration menu
    Copy the full SHA
    cb8190c View commit details
    Browse the repository at this point in the history