GithubHelp home page GithubHelp logo

Comments (3)

kravets-levko avatar kravets-levko commented on August 26, 2024 1

Hi @timtucker-dte! So:

  1. client instance can be safely used as singleton. Probably the only advice here could be to have an instance per connection options set (host + path + auth creds - things you pass to client.connect()). Depending on your use case, you may call connect() many times on same client, passing different options, but you'd have to close client before second and subsequent connect calls.
  2. session could also be used as a singleton, but keep in mind that after some period of inactivity it will expire and you'll start getting error on any operation running against the session.

Both client and session objects should eventually be closed to free up resources they use. When you do this depends on your use case. Client instance itself doesn't expire, and can be used as long as you need. Sessions (as mentioned) will expire if not used. So if, for example, your code executes some queries frequently it makes sense to keep and re-use session object - it will save some time and network requests. If your script runs, say, every hour, - it's better to create a new session each time and close it when script finishes, so you don't have to deal with expired sessions.

Hope this clarifies things a bit, but feel free to ask if any questions

from databricks-sql-nodejs.

timtucker-dte avatar timtucker-dte commented on August 26, 2024

Thanks!

For a session, how would we tell that it's expired?
Is there an event that we should be listening for / an error that we can catch?
Is there a good way to tell whether or not a session currently has operations pending?

Ideally what we're looking for is the equivalent of what we can get using connection pooling libraries with other SDKs, where most of the object management gets taken care of automatically behind the scenes.

from databricks-sql-nodejs.

kravets-levko avatar kravets-levko commented on August 26, 2024

For a session, how would we tell that it's expired?

We cannot until we try to use it. It's a big problem for developers of all connectors, and we don't have anh solution for this so far.

Is there an event that we should be listening for / an error that we can catch?

I need to double-check, but if I recall correctly - you'll just get a HTTP 404 when trying to use an expired session

Is there a good way to tell whether or not a session currently has operations pending?

I'm curiour what's a use case for it?

from databricks-sql-nodejs.

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.