UNPKG

wechaty-token

Version:

Wechaty Token Based Authentication Manager

24 lines 979 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.retryPolicy = void 0; const cockatiel_1 = require("cockatiel"); const config_js_1 = require("./config.js"); /** * Create a retry policy that'll try whatever function we execute 3 * times with a randomized exponential backoff. * * https://github.com/connor4312/cockatiel#policyretry */ const retryPolicy = getRetryPolicy(); exports.retryPolicy = retryPolicy; function getRetryPolicy() { const policy = cockatiel_1.Policy .handleAll() .retry() .attempts(3) .exponential(); policy.onRetry(reason => config_js_1.log.silly('wechaty-token', 'retry-policy getRetryPolicy policy.onRetry() reason: "%s"', JSON.stringify(reason))); policy.onSuccess(({ duration }) => config_js_1.log.silly('wechaty-token', 'retry-policy getRetryPolicy policy.onSuccess(): retry call ran in %s ms', duration)); return policy; } //# sourceMappingURL=retry-policy.js.map