UNPKG

rpc_ts

Version:

Remote Procedure Calls in TypeScript made simple

34 lines 993 B
"use strict"; /** * Simple exponential backoff strategy. * * @module ModuleRpcClient * * @license * Copyright (c) Aiden.ai * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ Object.defineProperty(exports, "__esModule", { value: true }); /** Default options for an exponential backoff. */ exports.DEFAULT_BACKOFF_OPTIONS = { exponentialBackoffBase: 2, constantBackoffMs: 500, maxBackoffMs: 3000, maxRetries: -1, }; /** * Gets the number of milliseconds to elapse for a given number of retries * and a backoff schedule. */ function getBackoffMs(options, retries) { let backoffMs = Math.pow(options.exponentialBackoffBase, retries) * options.constantBackoffMs; if (options.maxBackoffMs > 0 && backoffMs > options.maxBackoffMs) { backoffMs = options.maxBackoffMs; } return backoffMs; } exports.getBackoffMs = getBackoffMs; //# sourceMappingURL=backoff.js.map