Merge pull request #1987 from cosmin19/bugfix/grpc-js-pass-backoff-options-to-backofftimeout

grpc-js: Send backoffOptions to BackoffTimeout
This commit is contained in:
Michael Lumish 2021-12-13 11:03:32 -08:00 committed by GitHub
commit 0a40a79dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -26,7 +26,7 @@ import { ConnectivityState } from './connectivity-state';
import { ConfigSelector, createResolver, Resolver } from './resolver'; import { ConfigSelector, createResolver, Resolver } from './resolver';
import { ServiceError } from './call'; import { ServiceError } from './call';
import { Picker, UnavailablePicker, QueuePicker } from './picker'; import { Picker, UnavailablePicker, QueuePicker } from './picker';
import { BackoffTimeout } from './backoff-timeout'; import { BackoffOptions, BackoffTimeout } from './backoff-timeout';
import { Status } from './constants'; import { Status } from './constants';
import { StatusObject } from './call-stream'; import { StatusObject } from './call-stream';
import { Metadata } from './metadata'; import { Metadata } from './metadata';
@ -248,7 +248,10 @@ export class ResolvingLoadBalancer implements LoadBalancer {
}, },
channelOptions channelOptions
); );
const backoffOptions: BackoffOptions = {
initialDelay: channelOptions['grpc.initial_reconnect_backoff_ms'],
maxDelay: channelOptions['grpc.max_reconnect_backoff_ms'],
};
this.backoffTimeout = new BackoffTimeout(() => { this.backoffTimeout = new BackoffTimeout(() => {
if (this.continueResolving) { if (this.continueResolving) {
this.updateResolution(); this.updateResolution();
@ -256,7 +259,7 @@ export class ResolvingLoadBalancer implements LoadBalancer {
} else { } else {
this.updateState(this.latestChildState, this.latestChildPicker); this.updateState(this.latestChildState, this.latestChildPicker);
} }
}); }, backoffOptions);
this.backoffTimeout.unref(); this.backoffTimeout.unref();
} }