gremlin-javascript icon indicating copy to clipboard operation
gremlin-javascript copied to clipboard

add client.terminate()

Open abdullahshahin opened this issue 8 years ago • 3 comments

enable the client to close the web socket once they're need it, this method will make sure all commands have been done executing and then it will close the socket

let gremlin = require('gremlin-secure');
const client = gremlin.createClient(
        443,
        "someURL.graphs.azure.com",
        {
            session: false,
            ssl: true,
            user: "/dbs/test/colls/test",
            password: "secretPassword"
        }
        );
for(var i =0; i < 30; i++){
      client.execute('g.V().has("id", id)', { id: 'shahin' }, (err, results) => {
          if (err) {
              return console.error(err)
          }
          console.log(results);
      });
}
client.terminate();

abdullahshahin avatar Jul 15 '17 17:07 abdullahshahin

I don't think setInterval is the right thing to do here. Could you please share what you had in mind?

jbmusso avatar Aug 07 '17 15:08 jbmusso

make sure all commands have been executed, once terminate is submitted, there is a chance to have some commands are still being processed and the response is not delivered yet, so am setting the interval to keep checking whether its a good time to end the web socket, I have a use case to insert thousands of entries using async.eachLimit and every time I got 50 transitions, the 50 transactions may not delivered in time. I may realize that this could occupy a cpu power, is there any better way we can handle it differently ?

abdullahshahin avatar Aug 07 '17 17:08 abdullahshahin

I think my pull request covers this?

https://github.com/jbmusso/gremlin-javascript/pull/81

brianfoody avatar Aug 29 '17 13:08 brianfoody