Code Monkey home page Code Monkey logo

Comments (5)

jbmusso avatar jbmusso commented on June 2, 2024

Thanks - I just pushed a commit. I take a lot of inspiration from node_redis so I named the event error (see https://github.com/NodeRedis/node_redis#connection-events).

I also need to add a way to automatically reconnect. Using https://www.npmjs.com/package/retry could help, but I need to give it more thought.

from gremlin-javascript.

davidrapin avatar davidrapin commented on June 2, 2024

Thank you for the swift fix. However, the 'error' event is already used for query errors, so any use-case that I can think of would need an if inside the event handler to differentiate connection errors from query errors.

Example:

function connectClient = function(host, port, done) {
  var client = gremlin.createClient(host, port);
  client.on('connect', function() {
    done(null, client);
  }).on('error', function(err) {
    // could be a query error after connection has already succeeded
   if (!client.connected) {
     done(err);
   }
  });

I believe it would be much simpler to have different event names for connection errors and query errors.

from gremlin-javascript.

jbmusso avatar jbmusso commented on June 2, 2024

Ah, I see what you mean. Let me think that through, there might indeed be a better way to name that event or to distinguish between client events and query (= ReadableStream) events.

from gremlin-javascript.

jbmusso avatar jbmusso commented on June 2, 2024

I'm thinking about adding a disconnect event at the client level (= Websocket disconnection errors) in order to distinguish from the current error event which can be emitted by result steams when using the .stream() API. Unless I'm mistaken, the client instance doesn't emit an error event should a stream error actually occur, though I might be wrong on that one - I'll have to check/test that.

Feel free to provide feedback!

from gremlin-javascript.

davidrapin avatar davidrapin commented on June 2, 2024

I'm no t sure about the  disconnect semantics as this can happen if connection never took place (e.g.: tried to connect but failed because the provided port was wrong).

from gremlin-javascript.

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.