Skip to content

Allow Connection's transport connection to stay open #219

@kadler

Description

@kadler

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestkeep-openExempts stale action from auto closing the issue/pr.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions