UNPKG

@grouparoo/core

Version:
36 lines (35 loc) 983 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RetryableTask = void 0; const actionhero_1 = require("actionhero"); const clsTask_1 = require("./clsTask"); function getBackoffStrategy() { if (!actionhero_1.env || actionhero_1.env === "development") return [1000, 5 * 1000, 10 * 1000]; if (actionhero_1.env === "test") return [1000]; return [ 1 * 1000, 10 * 1000, 60 * 1000, 60 * 1000 * 5, 60 * 1000 * 10, 60 * 1000 * 30, // 30 minutes ]; } function getRetryLimit() { return getBackoffStrategy().length; } class RetryableTask extends clsTask_1.CLSTask { constructor() { super(); this.plugins = ["QueueLock", "Retry"]; this.pluginOptions = { Retry: { retryLimit: getRetryLimit(), backoffStrategy: getBackoffStrategy(), }, }; } } exports.RetryableTask = RetryableTask;