UNPKG

@deliverr/serverless-offline-step-functions

Version:

Serverless Offline Plugin to Support Step Functions for Local Development

34 lines (33 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Retrier = void 0; class Retrier { constructor(_ErrorEquals, _IntervalSeconds = 1, _MaxAttempts = 3, _BackoffRate = 2.0) { this._ErrorEquals = _ErrorEquals; this._IntervalSeconds = _IntervalSeconds; this._MaxAttempts = _MaxAttempts; this._BackoffRate = _BackoffRate; this._currentNumberOfRetries = 0; this._currentIntervalSeconds = _IntervalSeconds; } static create(taskRetryRule) { return new Retrier(taskRetryRule.ErrorEquals, taskRetryRule.IntervalSeconds, taskRetryRule.MaxAttempts, taskRetryRule.BackoffRate); } shouldRetry() { return this._currentNumberOfRetries < this._MaxAttempts; } retried() { this._currentNumberOfRetries = this._currentNumberOfRetries + 1; this._currentIntervalSeconds = this._currentIntervalSeconds * this._BackoffRate; } get currentNumberOfRetries() { return this._currentNumberOfRetries; } get currentIntervalSeconds() { return this._currentIntervalSeconds; } get ErrorEquals() { return this._ErrorEquals; } } exports.Retrier = Retrier;