nestjs-resilience
Version:
A module for improving the reliability and fault-tolerance of your NestJS applications
17 lines (16 loc) • 618 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EqualJitterBackoff = void 0;
const utils_1 = require("../utils");
const base_backoff_1 = require("./base.backoff");
class EqualJitterBackoff extends base_backoff_1.Backoff {
*getGenerator(maxRetries) {
let attempt = 0;
while (attempt < maxRetries) {
const exponentialDelay = this.baseDelay * Math.pow(2, attempt);
yield exponentialDelay / 2 + utils_1.Random.Between(0, exponentialDelay / 2 + 1);
attempt += 1;
}
}
}
exports.EqualJitterBackoff = EqualJitterBackoff;
;