Skip to content

Commit

Permalink
core: correctly locate maxRetries option (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus authored and callmehiphop committed Jun 6, 2016
1 parent afd9ce3 commit e4c3d55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/common/grpc-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function GrpcService(config, options) {
this.grpcCredentials = grpc.credentials.createInsecure();
}

this.maxRetries = config.maxRetries;
this.maxRetries = options.maxRetries;

var apiVersion = config.apiVersion;
var service = this.service = config.service;
Expand Down Expand Up @@ -257,7 +257,7 @@ GrpcService.prototype.request = function(protoOpts, reqOpts, callback) {
return [429, 500, 502, 503].indexOf(resp.code) > -1;
},

maxRetries: this.maxRetries,
retries: this.maxRetries,

// retry-request determines if it should retry from the incoming HTTP
// response status. gRPC always returns an error proto message. We pass that
Expand Down
11 changes: 6 additions & 5 deletions test/common/grpc-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ describe('GrpcService', function() {
var CONFIG = {
proto: {},
service: 'Service',
apiVersion: 'v1',
maxRetries: 3
apiVersion: 'v1'
};

var OPTIONS = {};
var OPTIONS = {
maxRetries: 3
};
var ROOT_DIR = '/root/dir';
var PROTO_FILE_PATH = 'filepath.proto';

Expand Down Expand Up @@ -239,7 +240,7 @@ describe('GrpcService', function() {
});

it('should localize maxRetries', function() {
assert.strictEqual(grpcService.maxRetries, CONFIG.maxRetries);
assert.strictEqual(grpcService.maxRetries, OPTIONS.maxRetries);
});

it('should get the root directory for the proto files', function(done) {
Expand Down Expand Up @@ -489,7 +490,7 @@ describe('GrpcService', function() {

assert.strictEqual(retryRequestReqOpts, null);
assert.strictEqual(
retryRequestOptions.maxRetries,
retryRequestOptions.retries,
grpcService.maxRetries
);

Expand Down

0 comments on commit e4c3d55

Please sign in to comment.