@hotmeshio/hotmesh
Version:
Serverless Workflow
135 lines (134 loc) • 7.14 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.HMSH_GUID_SIZE = exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_MESHFLOW_EXP_BACKOFF = exports.HMSH_MESHFLOW_MAX_INTERVAL = exports.HMSH_MESHFLOW_MAX_ATTEMPTS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_MAX_RETRIES = exports.MAX_DELAY = exports.MAX_STREAM_RETRIES = exports.INITIAL_STREAM_BACKOFF = exports.MAX_STREAM_BACKOFF = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_DEPLOYMENT_PAUSE = exports.HMSH_DEPLOYMENT_DELAY = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_MESHFLOW_RETRYABLE = exports.HMSH_CODE_MESHFLOW_FATAL = exports.HMSH_CODE_MESHFLOW_MAXED = exports.HMSH_CODE_MESHFLOW_TIMEOUT = exports.HMSH_CODE_MESHFLOW_WAIT = exports.HMSH_CODE_MESHFLOW_PROXY = exports.HMSH_CODE_MESHFLOW_CHILD = exports.HMSH_CODE_MESHFLOW_ALL = exports.HMSH_CODE_MESHFLOW_SLEEP = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_SIGNAL_EXPIRE = exports.HMSH_IS_CLUSTER = exports.HMSH_TELEMETRY = exports.HMSH_LOGLEVEL = void 0;
/**
* Determines the log level for the application. The default is 'info'.
*/
exports.HMSH_LOGLEVEL = process.env.HMSH_LOGLEVEL || 'info';
/**
* Determines the log level for telemetry. The default is 'info' which emits worker and trigger spans. 'debug' emits all spans.
*/
exports.HMSH_TELEMETRY = process.env.HMSH_TELEMETRY || 'info';
/**
* If Redis, explicitly sets whether the application is running in a cluster. The default is false.
* @deprecated
*/
exports.HMSH_IS_CLUSTER = process.env.HMSH_IS_CLUSTER === 'true';
/**
* Default cleanup time for signal in the db when its associated job is completed.
*/
exports.HMSH_SIGNAL_EXPIRE = 3600; //seconds
// HOTMESH STATUS CODES
exports.HMSH_CODE_SUCCESS = 200;
exports.HMSH_CODE_PENDING = 202;
exports.HMSH_CODE_NOTFOUND = 404;
exports.HMSH_CODE_INTERRUPT = 410;
exports.HMSH_CODE_UNKNOWN = 500;
exports.HMSH_CODE_TIMEOUT = 504;
exports.HMSH_CODE_UNACKED = 999;
// MESHFLOW STATUS CODES
/**
* This is thrown when a Meshflow has been interrupted by a sleepFor call.
*/
exports.HMSH_CODE_MESHFLOW_SLEEP = 588;
/**
* This is thrown when a Meshflow has been interrupted by a Promise.all call.
*/
exports.HMSH_CODE_MESHFLOW_ALL = 589;
/**
* This is thrown when a Meshflow has been interrupted by an execChild or startChild call.
*/
exports.HMSH_CODE_MESHFLOW_CHILD = 590;
/**
* This is thrown when a Meshflow has been interrupted by a proxyActivity call.
*/
exports.HMSH_CODE_MESHFLOW_PROXY = 591;
/**
* This is thrown when a Meshflow has been interrupted by a waitForSignal call.
*/
exports.HMSH_CODE_MESHFLOW_WAIT = 595;
/**
* The timeout status code for Meshflow. This status code is thrown when Meshflow has encountered a timeout error and needs to aler the caller why the call failed.
*/
exports.HMSH_CODE_MESHFLOW_TIMEOUT = 596;
/**
* The maxed status code for Meshflow. This status code is used to indicate that the Meshflow has reached the maximum
* number of attempts and should be halted. Thrown from a proxied activity or a flow to halt standard execution
* and prevent further attempts.
*/
exports.HMSH_CODE_MESHFLOW_MAXED = 597;
/**
* The fatal status code for Meshflow. This status code is used to indicate that the Meshflow has encountered a fatal error. Throw from a proxied activity or a flow to halt standard execution.
*/
exports.HMSH_CODE_MESHFLOW_FATAL = 598;
/**
* The retryable status code for Meshflow. This status code is used to indicate that the Meshflow has encountered a retryable error (essentially unknown and covered by the standard retry policy).
*/
exports.HMSH_CODE_MESHFLOW_RETRYABLE = 599;
// HOTMESH MESSAGES
exports.HMSH_STATUS_UNKNOWN = 'unknown';
// QUORUM
/**
* The number of cycles to re/try for a quorum to be established.
*/
exports.HMSH_QUORUM_ROLLCALL_CYCLES = 12;
/**
* The delay in milliseconds between quorum rollcall cycles.
*/
exports.HMSH_QUORUM_DELAY_MS = 250;
/**
* The number of times the call-response exchange must succeed in succession to establish a quorum.
*/
exports.HMSH_ACTIVATION_MAX_RETRY = 3;
//backend provisioning
exports.HMSH_DEPLOYMENT_DELAY = parseInt(process.env.HMSH_DEPLOYMENT_DELAY, 10) || 10000; //in ms
exports.HMSH_DEPLOYMENT_PAUSE = parseInt(process.env.HMSH_DEPLOYMENT_PAUSE, 10) || 250; //in ms
// ENGINE
exports.HMSH_OTT_WAIT_TIME = parseInt(process.env.HMSH_OTT_WAIT_TIME, 10) || 1000;
exports.HMSH_EXPIRE_JOB_SECONDS = parseInt(process.env.HMSH_EXPIRE_JOB_SECONDS, 10) || 1;
// STREAM ROUTER
exports.MAX_STREAM_BACKOFF = parseInt(process.env.MAX_STREAM_BACKOFF, 10) || 500;
exports.INITIAL_STREAM_BACKOFF = parseInt(process.env.INITIAL_STREAM_BACKOFF, 10) || 250;
exports.MAX_STREAM_RETRIES = parseInt(process.env.MAX_STREAM_RETRIES, 10) || 2;
exports.MAX_DELAY = 2147483647; // Maximum allowed delay in milliseconds for setTimeout
exports.HMSH_MAX_RETRIES = parseInt(process.env.HMSH_MAX_RETRIES, 10) || 3;
exports.HMSH_MAX_TIMEOUT_MS = parseInt(process.env.HMSH_MAX_TIMEOUT_MS, 10) || 60000;
exports.HMSH_GRADUATED_INTERVAL_MS = parseInt(process.env.HMSH_GRADUATED_INTERVAL_MS, 10) || 5000;
// MESHFLOW
/**
* The maximum number of attempts to retry a MeshFlow job before it is considered failed.
* @default 3
*/
exports.HMSH_MESHFLOW_MAX_ATTEMPTS = 3;
/**
* The maximum interval to wait before retrying a MeshFlow job.
* @default 120s
*/
exports.HMSH_MESHFLOW_MAX_INTERVAL = '120s';
/**
* The exponential backoff factor to apply to the interval between retries.
* @default 10
*/
exports.HMSH_MESHFLOW_EXP_BACKOFF = 10;
const BASE_BLOCK_DURATION = 10000;
const TEST_BLOCK_DURATION = 1000;
exports.HMSH_BLOCK_TIME_MS = process.env.HMSH_BLOCK_TIME_MS
? parseInt(process.env.HMSH_BLOCK_TIME_MS, 10)
: process.env.NODE_ENV === 'test'
? TEST_BLOCK_DURATION
: BASE_BLOCK_DURATION;
exports.HMSH_XCLAIM_DELAY_MS = parseInt(process.env.HMSH_XCLAIM_DELAY_MS, 10) || 1000 * 60;
exports.HMSH_XCLAIM_COUNT = parseInt(process.env.HMSH_XCLAIM_COUNT, 10) || 3;
exports.HMSH_XPENDING_COUNT = parseInt(process.env.HMSH_XPENDING_COUNT, 10) || 10;
// TASK WORKER
exports.HMSH_EXPIRE_DURATION = parseInt(process.env.HMSH_EXPIRE_DURATION, 10) || 1;
const BASE_FIDELITY_SECONDS = 5;
const TEST_FIDELITY_SECONDS = 1;
exports.HMSH_FIDELITY_SECONDS = process.env.HMSH_FIDELITY_SECONDS
? parseInt(process.env.HMSH_FIDELITY_SECONDS, 10)
: process.env.NODE_ENV === 'test'
? TEST_FIDELITY_SECONDS
: BASE_FIDELITY_SECONDS;
exports.HMSH_SCOUT_INTERVAL_SECONDS = parseInt(process.env.HMSH_SCOUT_INTERVAL_SECONDS, 10) || 60;
// UTILS
exports.HMSH_GUID_SIZE = Math.min(parseInt(process.env.HMSH_GUID_SIZE, 10) || 22, 32);
;