Skip to content

Conversation

crystall-bitquill
Copy link
Contributor

Summary

Wrapper client setKeepAlive method

Description

  • adds a setKeepAlive method to the wrapper clients, which if possible, will set keepalive based on the underlying driver

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@crystall-bitquill crystall-bitquill added the ready for review Pull requests that are ready to be reviewed label Nov 28, 2024
@@ -26,6 +26,7 @@ import { HostInfo } from "../../../common/lib/host_info";

export class MySQL2DriverDialect implements DriverDialect {
protected dialectName: string = this.constructor.name;
keepAlivePropertyNames: string[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is not a static constant? can this be modified?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the type is string[], not just string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a string[] because there could be multiple properties, for example PG having both keepalive and keepaliveInitialDelayMillis

@crystall-bitquill crystall-bitquill force-pushed the feat/tcp-keepalive branch 2 times, most recently from 5fe5632 to abe26ca Compare December 6, 2024 18:31
@@ -52,4 +52,6 @@ export class MySQL2DriverDialect implements DriverDialect {
getAwsPoolClient(props: PoolOptions): AwsPoolClient {
return new AwsMysqlPoolClient(props);
}

setupInitialProperties(props: Map<string, any>) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we notify user that this feature isn't supported by mysql driver if the user provides tcpKeepAlive configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a note in the UsingTheNodejsWrapper.md file, do you think that's sufficient?

@@ -58,6 +58,8 @@ export abstract class AwsClient extends EventEmitter {

this.properties = new Map<string, any>(Object.entries(config));

driverDialect.setupInitialProperties(this.properties);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to setup these properties in connection provider connect() method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or in driver dialect connect()

@crystall-bitquill crystall-bitquill force-pushed the feat/tcp-keepalive branch 3 times, most recently from 970ac66 to 33b1444 Compare December 7, 2024 00:38
@@ -52,4 +52,6 @@ export class MySQL2DriverDialect implements DriverDialect {
getAwsPoolClient(props: PoolOptions): AwsPoolClient {
return new AwsMysqlPoolClient(props);
}

setKeepAliveProperties(props: Map<string, any>, keepAliveProps: any) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since mysql driver doesn't support tcpKeepAlive I'd suggest to check keepAliveProp and if it set then raise an exception saying that the driver doesn't support it.

@karenc-bq karenc-bq merged commit e58e8e9 into main Dec 11, 2024
2 checks passed
@karenc-bq karenc-bq deleted the feat/tcp-keepalive branch December 11, 2024 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review Pull requests that are ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants