fix(microservices): fix redis retrying strategy (recover)

This commit is contained in:
Kamil Myśliwiec
2019-07-01 14:37:36 +02:00
parent 77a8027fef
commit 75c541ad30
7 changed files with 62 additions and 28 deletions

View File

@@ -102,14 +102,15 @@ export class ClientRedis extends ClientProxy {
): undefined | number | Error {
if (options.error && (options.error as any).code === ECONNREFUSED) {
error$.error(options.error);
return options.error;
}
if (this.isExplicitlyTerminated) {
return undefined;
}
if (
this.isExplicitlyTerminated ||
!this.getOptionsProp(this.options, 'retryAttempts') ||
options.attempt > this.getOptionsProp(this.options, 'retryAttempts')
) {
return undefined;
return new Error('Retry time exhausted');
}
return this.getOptionsProp(this.options, 'retryDelay') || 0;
}