|
1 | 1 | // AWS Aurora MySQL Data API Client |
2 | 2 | // ------- |
| 3 | +const { ExecuteStatementCommand, RDSDataClient } = require('@aws-sdk/client-rds-data'); |
| 4 | +const { NodeHttpHandler } = require('@smithy/node-http-handler'); |
3 | 5 | const map = require('lodash.map'); |
4 | 6 | const Client_MySQL = require('knex/lib/dialects/mysql'); // eslint-disable-line camelcase |
5 | 7 | const Transaction = require('./transaction'); |
@@ -61,23 +63,27 @@ class Client_AuroraDataMySQL extends Client_MySQL { // eslint-disable-line camel |
61 | 63 | _driver () { |
62 | 64 | let RDSDataService; |
63 | 65 | try { |
64 | | - RDSDataService = require('aws-sdk/clients/rdsdataservice'); |
| 66 | + RDSDataService = RDSDataClient; |
65 | 67 | } catch (err) { /* istanbul ignore next */ |
66 | 68 | throw new Error(`Failed to load aws-sdk rdsdataservice client, did you forget to install it as a dependency? (${err.message})`); |
67 | 69 | } |
68 | 70 |
|
69 | | - const https = this.config.connection.sdkConfig && String(this.config.connection.sdkConfig.endpoint).startsWith('http:') |
| 71 | + const isHttp = this.config.connection.sdkConfig && String(this.config.connection.sdkConfig.endpoint).startsWith('http:'); |
| 72 | + |
| 73 | + const https = isHttp |
70 | 74 | ? require('http') |
71 | 75 | : require('https'); |
72 | 76 |
|
73 | 77 | const agent = new https.Agent({ |
74 | 78 | keepAlive: true |
75 | 79 | }); |
76 | 80 |
|
| 81 | + const requestHandler = new NodeHttpHandler({ |
| 82 | + [isHttp ? 'httpAgent' : 'httpsAgent']: agent |
| 83 | + }); |
| 84 | + |
77 | 85 | const config = { |
78 | | - httpOptions: { |
79 | | - agent |
80 | | - }, |
| 86 | + requestHandler, |
81 | 87 | ...(this.config.connection.sdkConfig || {}) |
82 | 88 | }; |
83 | 89 |
|
@@ -221,9 +227,9 @@ class Client_AuroraDataMySQL extends Client_MySQL { // eslint-disable-line camel |
221 | 227 | params.transactionId = connection.transactions[connection.__knexTxId]; |
222 | 228 | } |
223 | 229 |
|
224 | | - obj.data = await connection.client |
225 | | - .executeStatement(params) |
226 | | - .promise(); |
| 230 | + const command = new ExecuteStatementCommand(params); |
| 231 | + |
| 232 | + obj.data = await connection.client.send(command); |
227 | 233 |
|
228 | 234 | return obj; |
229 | 235 | } |
|
0 commit comments