Skip to content

Commit

Permalink
Retry on RDSDataService Communications link failure (#2931)
Browse files Browse the repository at this point in the history
* Retry on RDSDataService Communications link failure
  • Loading branch information
thomasmichaelwallace authored and AllanZhengYP committed Jan 9, 2020
1 parent 3f6547e commit bf1ebe0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/feature-RDSDataService-a799b536.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "RDSDataService",
"description": "Retry on Serverless Aurora \"Communications link failure\""
}
1 change: 1 addition & 0 deletions clients/rdsdataservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
19 changes: 19 additions & 0 deletions lib/services/rdsdataservice.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
});
33 changes: 33 additions & 0 deletions test/services/rdsdataservice.spec.js
Original file line number Diff line number Diff line change
@@ -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'];
});
});
});

0 comments on commit bf1ebe0

Please sign in to comment.