Skip to content

Commit

Permalink
⚡ keepAlive always on
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Apr 8, 2024
1 parent 8b39f72 commit 6348021
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export async function initDB(this: ITriggerFunctions | ILoadOptionsFunctions) {
const options = this.getNodeParameter('options', {}) as {
connectionTimeout?: number;
delayClosingIdleConnection?: number;
keepAlive?: boolean;
};
const pgp = pgPromise({
// prevent spam in console "WARNING: Creating a duplicate database object for the same connection."
Expand All @@ -102,16 +101,13 @@ export async function initDB(this: ITriggerFunctions | ILoadOptionsFunctions) {
database: credentials.database as string,
user: credentials.user as string,
password: credentials.password as string,
keepAlive: true,
};

if (options.connectionTimeout) {
config.connectionTimeoutMillis = options.connectionTimeout * 1000;
}

if (options.keepAlive) {
config.keepAlive = options.keepAlive;
}

if (options.delayClosingIdleConnection) {
config.keepAliveInitialDelayMillis = options.delayClosingIdleConnection * 1000;
}
Expand Down
7 changes: 0 additions & 7 deletions packages/nodes-base/nodes/Postgres/PostgresTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,6 @@ export class PostgresTrigger implements INodeType {
minValue: 0,
},
},
{
displayName: 'Keep Alive',
name: 'keepAlive',
type: 'boolean',
default: false,
description: 'Whether to keep the connection alive',
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ export const optionsCollection: INodeProperties = {
minValue: 0,
},
},
{
displayName: 'Keep Alive',
name: 'keepAlive',
type: 'boolean',
default: false,
description: 'Whether to keep the connection alive',
},
{
displayName: 'Query Batching',
name: 'queryBatching',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export type PostgresNodeOptions = {
cascade?: boolean;
connectionTimeout?: number;
delayClosingIdleConnection?: number;
keepAlive?: boolean;
queryBatching?: QueryMode;
queryReplacement?: string;
outputColumns?: string[];
Expand Down
5 changes: 1 addition & 4 deletions packages/nodes-base/nodes/Postgres/v2/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,13 @@ export async function configurePostgres(
database: credentials.database,
user: credentials.user,
password: credentials.password,
keepAlive: true,
};

if (options.connectionTimeout) {
dbConfig.connectionTimeoutMillis = options.connectionTimeout * 1000;
}

if (options.keepAlive) {
dbConfig.keepAlive = options.keepAlive;
}

if (options.delayClosingIdleConnection) {
dbConfig.keepAliveInitialDelayMillis = options.delayClosingIdleConnection * 1000;
}
Expand Down

0 comments on commit 6348021

Please sign in to comment.