-
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.
fix: use dynamic imports for plugins construction
- Loading branch information
1 parent
df1de6c
commit 7c16643
Showing
22 changed files
with
313 additions
and
93 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
34 changes: 34 additions & 0 deletions
34
common/lib/authentication/aws_secrets_manager_plugin_factory.ts
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,34 @@ | ||
/* | ||
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 { ConnectionPluginFactory } from "../plugin_factory"; | ||
import { PluginService } from "../plugin_service"; | ||
import { ConnectionPlugin } from "../connection_plugin"; | ||
import { AwsWrapperError } from "../utils/errors"; | ||
import { Messages } from "../utils/messages"; | ||
import { logger } from "../../logutils"; | ||
|
||
export class AwsSecretsManagerPluginFactory implements ConnectionPluginFactory { | ||
async getInstance(pluginService: PluginService, properties: Map<string, any>): Promise<ConnectionPlugin> { | ||
try { | ||
const awsSecretsManagerPlugin = await import("./aws_secrets_manager_plugin"); | ||
return new awsSecretsManagerPlugin.AwsSecretsManagerPlugin(pluginService, new Map(properties)); | ||
} catch (error: any) { | ||
logger.error(error); | ||
throw new AwsWrapperError(Messages.get("ConnectionPluginChainBuilder.errorImportingPlugin", "AwsSecretsManagerPlugin")); | ||
} | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
common/lib/authentication/iam_authentication_plugin_factory.ts
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,34 @@ | ||
/* | ||
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 { ConnectionPluginFactory } from "../plugin_factory"; | ||
import { PluginService } from "../plugin_service"; | ||
import { ConnectionPlugin } from "../connection_plugin"; | ||
import { AwsWrapperError } from "../utils/errors"; | ||
import { Messages } from "../utils/messages"; | ||
import { logger } from "../../logutils"; | ||
|
||
export class IamAuthenticationPluginFactory implements ConnectionPluginFactory { | ||
async getInstance(pluginService: PluginService, properties: object): Promise<ConnectionPlugin> { | ||
try { | ||
const iamAuthenticationPlugin = await import("./iam_authentication_plugin"); | ||
return new iamAuthenticationPlugin.IamAuthenticationPlugin(pluginService); | ||
} catch (error: any) { | ||
logger.error(error); | ||
throw new AwsWrapperError(Messages.get("ConnectionPluginChainBuilder.errorImportingPlugin", "IamAuthenticationPlugin")); | ||
} | ||
} | ||
} |
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,34 @@ | ||
/* | ||
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 { ConnectionPluginFactory } from "../plugin_factory"; | ||
import { PluginService } from "../plugin_service"; | ||
import { ConnectionPlugin } from "../connection_plugin"; | ||
import { AwsWrapperError } from "../utils/errors"; | ||
import { Messages } from "../utils/messages"; | ||
import { logger } from "../../logutils"; | ||
|
||
export class ConnectTimePluginFactory implements ConnectionPluginFactory { | ||
async getInstance(pluginService: PluginService, properties: Map<string, any>): Promise<ConnectionPlugin> { | ||
try { | ||
const connectTimePlugin = await import("./connect_time_plugin"); | ||
return new connectTimePlugin.ConnectTimePlugin(); | ||
} catch (error: any) { | ||
logger.error(error); | ||
throw new AwsWrapperError(Messages.get("ConnectionPluginChainBuilder.errorImportingPlugin", "ConnectTimePlugin")); | ||
} | ||
} | ||
} |
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,34 @@ | ||
/* | ||
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 { ConnectionPluginFactory } from "../plugin_factory"; | ||
import { PluginService } from "../plugin_service"; | ||
import { ConnectionPlugin } from "../connection_plugin"; | ||
import { AwsWrapperError } from "../utils/errors"; | ||
import { Messages } from "../utils/messages"; | ||
import { logger } from "../../logutils"; | ||
|
||
export class ExecuteTimePluginFactory implements ConnectionPluginFactory { | ||
async getInstance(pluginService: PluginService, properties: Map<string, any>): Promise<ConnectionPlugin> { | ||
try { | ||
const executeTimePlugin = await import("./execute_time_plugin"); | ||
return new executeTimePlugin.ExecuteTimePlugin(); | ||
} catch (error: any) { | ||
logger.error(error); | ||
throw new AwsWrapperError(Messages.get("ConnectionPluginChainBuilder.errorImportingPlugin", "ExecuteTimePlugin")); | ||
} | ||
} | ||
} |
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,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 { ConnectionPluginFactory } from "../../plugin_factory"; | ||
import { PluginService } from "../../plugin_service"; | ||
import { ConnectionPlugin } from "../../connection_plugin"; | ||
import { RdsUtils } from "../../utils/rds_utils"; | ||
import { logger } from "../../../logutils"; | ||
import { AwsWrapperError } from "../../utils/errors"; | ||
import { Messages } from "../../utils/messages"; | ||
|
||
export class FailoverPluginFactory implements ConnectionPluginFactory { | ||
async getInstance(pluginService: PluginService, properties: Map<string, any>): Promise<ConnectionPlugin> { | ||
try { | ||
const failoverPlugin = await import("./failover_plugin"); | ||
return new failoverPlugin.FailoverPlugin(pluginService, properties, new RdsUtils()); | ||
} catch (error: any) { | ||
logger.error(error); | ||
throw new AwsWrapperError(Messages.get("ConnectionPluginChainBuilder.errorImportingPlugin", "FailoverPlugin")); | ||
} | ||
} | ||
} |
Oops, something went wrong.