Giter VIP home page Giter VIP logo

Comments (4)

mmcgrana avatar mmcgrana commented on June 26, 2024

(First off, thanks @samuel for the library. I was very happy to find a pure-Go Zookeper option!)

I recently ran into the issue raised by @onsi while working on the zk command line client based on this library. For reference, the error
looks like:

$ zk children /
2014/05/20 20:03:42 Failed to connect to 192.168.12.12:2182: dial tcp 192.168.12.12:2182: i/o timeout
2014/05/20 20:03:43 Failed to connect to 192.168.12.13:2182: dial tcp 192.168.12.13:2182: i/o timeout
2014/05/20 20:03:44 Failed to connect to 192.168.12.11:2182: dial tcp 192.168.12.11:2182: i/o timeout
2014/05/20 20:03:46 Failed to connect to 192.168.12.12:2182: dial tcp 192.168.12.12:2182: i/o timeout

Where the log messages above are emitted by the go-zookeeper library.

This is problematic for me for a couple reasons:

  • With control not returning to the caller in the case of connection-time errors I'm not able to present a good error message to the user.
  • The library emits log messages which I have no control over in terms of destination, formatting, etc.

@samuel do you have any thoughts about what could be done in the library and/or in calling code to handle connection-time errors to servers? I would be happy to make changes in my code and/or consider writing a patch for this library. Some ideas:

  • The caller just needs to set up their own timeout, perhaps calling Close if it hits the timeout branch.
  • If the library can't establish a connection with the first server it tries when Connect is called, return an error. Or return an error after all servers have been tried once. The calling code could retry Connects if it wanted to.
  • Some sort of pluggable logging setup (this would only address the second point above).

from go-zookeeper.

samuel avatar samuel commented on June 26, 2024

Sorry, I should gotten to this a while back :)

I'm not sure if a timeout or instant fail is the best and open to either option, but I implemented the instant fail when all servers are tried but none succeed. This I hope will solve the common problem of waiting forever. For logging, it's possible to add an optional way to set a custom logger (accepting a log.Logger interface), but I'll leave that for another patch.

#30

Let me know if this works for you. Thanks!

from go-zookeeper.

mmcgrana avatar mmcgrana commented on June 26, 2024

Hey @samuel, thanks, this does definitely help. With this change we're able to avoid looping forever in our CLI tool / having to force an out-of-band timeout.

There are still some log messages that get dumped, but as you mentioned we can circle back on that latter.

from go-zookeeper.

samuel avatar samuel commented on June 26, 2024

Merged #30

from go-zookeeper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.