Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
push:
branches:
- main
- dev/v3
paths-ignore:
- "**/*.md"
- "**/*.jpg"
Expand All @@ -14,6 +13,9 @@ on:
- "docs/**"
- "ISSUE_TEMPLATE/**"
- "**/remove-old-artifacts.yml"
pull_request:
branches:
- dev/v3

permissions:
id-token: write # This is required for requesting the JWT
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- "*"
- dev/v3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intentional. Will remove when merging dev/v3 branch into main


permissions:
contents: read
Expand Down
35 changes: 35 additions & 0 deletions common/lib/connection_info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { ClientWrapper } from "./client_wrapper";

export class ConnectionInfo {
private readonly _client: ClientWrapper;
private readonly _isPooled: boolean;

constructor(client: ClientWrapper, isPooled: boolean) {
this._client = client;
this._isPooled = isPooled;
}

get client(): ClientWrapper {
return this._client;
}

get isPooled(): boolean {
return this._isPooled;
}
}
4 changes: 2 additions & 2 deletions common/lib/connection_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import { HostRole } from "./host_role";
import { HostInfo } from "./host_info";
import { PluginService } from "./plugin_service";
import { ClientWrapper } from "./client_wrapper";
import { ConnectionInfo } from "./connection_info";

export interface ConnectionProvider {
connect(hostInfo: HostInfo, pluginService: PluginService, props: Map<string, any>): Promise<ClientWrapper>;
connect(hostInfo: HostInfo, pluginService: PluginService, props: Map<string, any>): Promise<ConnectionInfo>;
acceptsUrl(hostInfo: HostInfo, props: Map<string, any>): boolean;
acceptsStrategy(role: HostRole, strategy: string): boolean;
getHostInfoByStrategy(hosts: HostInfo[], role: HostRole, strategy: string, props?: Map<string, any>): HostInfo;
Expand Down
5 changes: 3 additions & 2 deletions common/lib/driver_connection_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { logger } from "../logutils";
import { ClientWrapper } from "./client_wrapper";
import { RoundRobinHostSelector } from "./round_robin_host_selector";
import { DriverDialect } from "./driver_dialect/driver_dialect";
import { ConnectionInfo } from "./connection_info";

export class DriverConnectionProvider implements ConnectionProvider {
private static readonly acceptedStrategies: Map<string, HostSelector> = new Map([
Expand All @@ -46,7 +47,7 @@ export class DriverConnectionProvider implements ConnectionProvider {
return true;
}

async connect(hostInfo: HostInfo, pluginService: PluginService, props: Map<string, any>): Promise<ClientWrapper> {
async connect(hostInfo: HostInfo, pluginService: PluginService, props: Map<string, any>): Promise<ConnectionInfo> {
let resultTargetClient;
const resultProps = new Map(props);
resultProps.set(WrapperProperties.HOST.name, hostInfo.host);
Expand Down Expand Up @@ -92,7 +93,7 @@ export class DriverConnectionProvider implements ConnectionProvider {
resultTargetClient = driverDialect.connect(hostInfo, resultProps);
}
pluginService.attachErrorListener(resultTargetClient);
return resultTargetClient;
return new ConnectionInfo(resultTargetClient, false);
}

getHostInfoByStrategy(hosts: HostInfo[], role: HostRole, strategy: string, props?: Map<string, any>): HostInfo {
Expand Down
5 changes: 3 additions & 2 deletions common/lib/internal_pooled_connection_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { LeastConnectionsHostSelector } from "./least_connections_host_selector"
import { PoolClientWrapper } from "./pool_client_wrapper";
import { logger } from "../logutils";
import { SlidingExpirationCacheWithCleanupTask } from "./utils/sliding_expiration_cache_with_cleanup_task";
import { ConnectionInfo } from "./connection_info";

export class InternalPooledConnectionProvider implements PooledConnectionProvider, CanReleaseResources {
static readonly CACHE_CLEANUP_NANOS: bigint = BigInt(10 * 60_000_000_000); // 10 minutes
Expand Down Expand Up @@ -79,7 +80,7 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
return RdsUrlType.RDS_INSTANCE === urlType;
}

async connect(hostInfo: HostInfo, pluginService: PluginService, props: Map<string, any>): Promise<ClientWrapper> {
async connect(hostInfo: HostInfo, pluginService: PluginService, props: Map<string, any>): Promise<ConnectionInfo> {
const resultProps = new Map(props);
resultProps.set(WrapperProperties.HOST.name, hostInfo.host);
if (hostInfo.isPortSpecified()) {
Expand Down Expand Up @@ -122,7 +123,7 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide

const poolClient = await this.getPoolConnection(connectionHostInfo, props);
pluginService.attachErrorListener(poolClient);
return poolClient;
return new ConnectionInfo(poolClient, true);
}

async getPoolConnection(hostInfo: HostInfo, props: Map<string, string>) {
Expand Down
14 changes: 14 additions & 0 deletions common/lib/plugin_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export interface PluginService extends ErrorHandler {
getStatus<T>(clazz: any, key: string): T;

isPluginInUse(plugin: any): boolean;

isPooledClient(): boolean;

setIsPooledClient(isPooledClient: boolean): void;
}

export class PluginServiceImpl implements PluginService, HostListProviderService {
Expand All @@ -172,6 +176,8 @@ export class PluginServiceImpl implements PluginService, HostListProviderService
protected static readonly statusesExpiringCache: CacheMap<string, any> = new CacheMap();
protected static readonly DEFAULT_STATUS_CACHE_EXPIRE_NANO: number = 3_600_000_000_000; // 60 minutes

protected pooledClient: boolean | null = null;

constructor(
container: PluginServiceManagerContainer,
client: AwsClient,
Expand Down Expand Up @@ -782,4 +788,12 @@ export class PluginServiceImpl implements PluginService, HostListProviderService
isPluginInUse(plugin: any) {
return this.pluginServiceManagerContainer.pluginManager!.isPluginInUse(plugin);
}

isPooledClient(): boolean | null {
return this.pooledClient;
}

setIsPooledClient(isPooledClient: boolean): void {
this.pooledClient = isPooledClient;
}
}
8 changes: 5 additions & 3 deletions common/lib/plugins/default_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { AwsWrapperError } from "../utils/errors";
import { HostAvailability } from "../host_availability/host_availability";
import { ClientWrapper } from "../client_wrapper";
import { TelemetryTraceLevel } from "../utils/telemetry/telemetry_trace_level";
import { ConnectionInfo } from "../connection_info";

export class DefaultPlugin extends AbstractConnectionPlugin {
id: string = uniqueId("_defaultPlugin");
Expand Down Expand Up @@ -79,10 +80,11 @@ export class DefaultPlugin extends AbstractConnectionPlugin {
TelemetryTraceLevel.NESTED
);

const result = await telemetryContext.start(async () => await connProvider.connect(hostInfo, this.pluginService, props));
const result: ConnectionInfo = await telemetryContext.start(async () => await connProvider.connect(hostInfo, this.pluginService, props));
this.pluginService.setAvailability(hostInfo.allAliases, HostAvailability.AVAILABLE);
await this.pluginService.updateDialect(result);
return result;
this.pluginService.setIsPooledClient(result.isPooled);
await this.pluginService.updateDialect(result.client);
return result.client;
}

override async execute<Type>(methodName: string, methodFunc: () => Promise<Type>): Promise<Type> {
Expand Down
Loading