-
Notifications
You must be signed in to change notification settings - Fork 38
Description
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.