diff --git a/.changes/next-release/feature-RDSDataService-a799b536.json b/.changes/next-release/feature-RDSDataService-a799b536.json new file mode 100644 index 0000000000..477beb6223 --- /dev/null +++ b/.changes/next-release/feature-RDSDataService-a799b536.json @@ -0,0 +1,5 @@ +{ + "type": "feature", + "category": "RDSDataService", + "description": "Retry on Serverless Aurora \"Communications link failure\"" +} \ No newline at end of file diff --git a/clients/rdsdataservice.js b/clients/rdsdataservice.js index 9711b0f157..553817bd80 100644 --- a/clients/rdsdataservice.js +++ b/clients/rdsdataservice.js @@ -5,6 +5,7 @@ var apiLoader = AWS.apiLoader; apiLoader.services['rdsdataservice'] = {}; AWS.RDSDataService = Service.defineService('rdsdataservice', ['2018-08-01']); +require('../lib/services/rdsdataservice'); Object.defineProperty(apiLoader.services['rdsdataservice'], '2018-08-01', { get: function get() { var model = require('../apis/rds-data-2018-08-01.min.json'); diff --git a/lib/services/rdsdataservice.js b/lib/services/rdsdataservice.js new file mode 100644 index 0000000000..40266e3a81 --- /dev/null +++ b/lib/services/rdsdataservice.js @@ -0,0 +1,19 @@ +var AWS = require('../core'); + +AWS.util.update(AWS.RDSDataService.prototype, { + /** + * @return [Boolean] whether the error can be retried + * @api private + */ + retryableError: function retryableError(error) { + if (error.code === 'BadRequestException' && + error.message && + error.message.match(/^Communications link failure/) && + error.statusCode === 400) { + return true; + } else { + var _super = AWS.Service.prototype.retryableError; + return _super.call(this, error); + } + } +}); diff --git a/test/services/rdsdataservice.spec.js b/test/services/rdsdataservice.spec.js new file mode 100644 index 0000000000..ff9ed2e3b5 --- /dev/null +++ b/test/services/rdsdataservice.spec.js @@ -0,0 +1,33 @@ +var AWS, helpers; + +helpers = require('../helpers'); + +AWS = helpers.AWS; + +describe('AWS.RDSDataService', function() { + var service; + beforeEach(function() { + service = new AWS.RDSDataService(); + }); + return describe('retryableError', function() { + it('retryableError returns true for Communications link failure errors', function() { + var err; + err = { + message: 'Communications link failure\n' + + '\n' + + 'The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.', + code: 'BadRequestException', + statusCode: 400 + }; + return expect(service.retryableError(err)).to.be['true']; + }); + return it('retryableError returns false for other 400 errors', function() { + var err; + err = { + code: 'SomeErrorCode', + statusCode: 400 + }; + return expect(service.retryableError(err)).to.be['false']; + }); + }); +});