nodejs-itoolkit icon indicating copy to clipboard operation
nodejs-itoolkit copied to clipboard

Allow Connection's transport connection to stay open

Open kadler opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Performance is not ideal with the current Connection behavior.

Describe the solution you'd like

Currently, Connection objects connect/disconnect on each call. We should have an option to have it connect once and stay open until the user explicitly disconnects for the transports that support such things (idb, odbc, ssh). This would have to be opt-in, as the user would then be necessary for closing out connections that would otherwise be leaked.

The proposed solution would be something like


const conn = new Connection({
  transport: 'ssh',
  transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' },
  persistent: true,  // or keepOpen or whatever
});
conn.add(...);

conn.run(...); // transport is implicitly opened
conn.run(...); // transport is re-used

conn.close();

conn.run(...); // transport is implicitly opened again

In this example the connection still implicitly opens the connection, it's just the user responsible for closing it. Alternatively, we could have the user explicitly open it as well.

When using the existing behavior, close() would be a no-op.

kadler avatar Mar 31 '20 23:03 kadler

:wave: Hi! This issue has been marked stale due to inactivity. If no further activity occurs, it will automatically be closed.

github-actions[bot] avatar May 01 '20 00:05 github-actions[bot]

Hey @kadler, what's the status here? Is this kind of functionality likely to be get implemented by someone else?

Is it worth me spending the time to create a PR for this and let it get reviewed?

Thanks!

worksofliam avatar Dec 09 '20 15:12 worksofliam