-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: separate database dialect and driver dialect (#235)
- Loading branch information
Showing
44 changed files
with
527 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
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"; | ||
import { AwsPoolConfig } from "../aws_pool_config"; | ||
import { AwsPoolClient } from "../aws_pool_client"; | ||
import { HostInfo } from "../host_info"; | ||
|
||
export interface DriverDialect { | ||
getDialectName(): string; | ||
|
||
connect(hostInfo: HostInfo, props: Map<string, any>): Promise<ClientWrapper>; | ||
|
||
preparePoolClientProperties(props: Map<string, any>, poolConfig: AwsPoolConfig | undefined): any; | ||
|
||
getAwsPoolClient(props: any): AwsPoolClient; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
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"; | ||
import { HostInfo } from "./host_info"; | ||
import { ClientUtils } from "./utils/client_utils"; | ||
|
||
/* | ||
This is an internal wrapper class for the target community driver client created by the MySQL2DriverDialect. | ||
*/ | ||
export class MySQLClientWrapper implements ClientWrapper { | ||
readonly client: any; | ||
readonly hostInfo: HostInfo; | ||
readonly properties: Map<string, string>; | ||
|
||
/** | ||
* Creates a wrapper for the target community driver client. | ||
* | ||
* @param targetClient The community driver client created for an instance. | ||
* @param hostInfo Host information for the connected instance. | ||
* @param properties Connection properties for the target client. | ||
*/ | ||
constructor(targetClient: any, hostInfo: HostInfo, properties: Map<string, any>) { | ||
this.client = targetClient; | ||
this.hostInfo = hostInfo; | ||
this.properties = properties; | ||
} | ||
|
||
query(sql: any): Promise<any> { | ||
return this.client?.query(sql); | ||
} | ||
|
||
end(): Promise<void> { | ||
return this.client?.end(); | ||
} | ||
|
||
rollback(): Promise<void> { | ||
return this.client?.rollback(); | ||
} | ||
|
||
async abort(): Promise<void> { | ||
try { | ||
return await ClientUtils.queryWithTimeout(this.client?.destroy(), this.properties); | ||
} catch (error: any) { | ||
// ignore | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
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"; | ||
import { HostInfo } from "./host_info"; | ||
|
||
/* | ||
This an internal wrapper class for a target community driver client created by the NodePostgresPgDriverDialect. | ||
*/ | ||
export class PgClientWrapper implements ClientWrapper { | ||
readonly client: any; | ||
readonly hostInfo: HostInfo; | ||
readonly properties: Map<string, string>; | ||
|
||
/** | ||
* Creates a wrapper for the target community driver client. | ||
* | ||
* @param targetClient The community driver client created for an instance. | ||
* @param hostInfo Host information for the connected instance. | ||
* @param properties Connection properties for the target client. | ||
*/ | ||
constructor(targetClient: any, hostInfo: HostInfo, properties: Map<string, any>) { | ||
this.client = targetClient; | ||
this.hostInfo = hostInfo; | ||
this.properties = properties; | ||
} | ||
|
||
query(sql: any): Promise<any> { | ||
return this.client?.query(sql); | ||
} | ||
|
||
end(): Promise<void> { | ||
return this.client?.end(); | ||
} | ||
|
||
rollback(): Promise<void> { | ||
return this.client?.rollback(); | ||
} | ||
|
||
async abort(): Promise<void> { | ||
try { | ||
return await this.end(); | ||
} catch (error: any) { | ||
// Ignore | ||
} | ||
} | ||
} |
Oops, something went wrong.