@defer.run/client
Advanced tools
Comparing version 0.1.0-alpha-20221220161057-7e53b27 to 0.1.0-alpha-20221220162232-f42c41b
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FN_EXECUTION_POLLING_INTERVAL_SECS = exports.TOKEN_ENV_NAME = exports.PATH = exports.DOMAIN = void 0; | ||
exports.INTERNAL_VERSION = exports.FN_EXECUTION_POLLING_INTERVAL = exports.TOKEN_ENV_NAME = exports.PATH = exports.DOMAIN = void 0; | ||
exports.DOMAIN = "https://api.defer.run"; | ||
exports.PATH = "/api/v1/"; | ||
exports.TOKEN_ENV_NAME = "DEFER_TOKEN"; | ||
exports.FN_EXECUTION_POLLING_INTERVAL_SECS = 2; | ||
exports.FN_EXECUTION_POLLING_INTERVAL = 1000; | ||
exports.INTERNAL_VERSION = 2; |
@@ -56,10 +56,4 @@ "use strict"; | ||
exports.serializeBackgroundFunctionArguments = serializeBackgroundFunctionArguments; | ||
const jitter = (attempt) => Math.floor(Math.random() * | ||
(Math.min(15, Math.pow(constants_js_1.FN_EXECUTION_POLLING_INTERVAL_SECS * 2, attempt)) - | ||
0 + | ||
1) + | ||
0); | ||
// TODO(charly): handler error cases | ||
function poolForExecutionResult(fnName, runId, fetcher, debug = false) { | ||
let attempt = 1; | ||
const getResult = async () => fetcher(`executions/${runId}`, { | ||
@@ -84,8 +78,7 @@ method: "GET", | ||
} | ||
setTimeout(poll, jitter(attempt++)); | ||
setTimeout(poll, constants_js_1.FN_EXECUTION_POLLING_INTERVAL); | ||
}; | ||
// initial call | ||
setTimeout(poll, jitter(attempt++)); | ||
poll(); | ||
}); | ||
} | ||
exports.poolForExecutionResult = poolForExecutionResult; |
@@ -40,2 +40,3 @@ "use strict"; | ||
ret.__fn = fn; | ||
ret.__version = constants_js_1.INTERNAL_VERSION; | ||
return ret; | ||
@@ -55,3 +56,4 @@ }; | ||
ret.__fn = fn; | ||
ret.__version = constants_js_1.INTERNAL_VERSION; | ||
return ret; | ||
}; |
export const DOMAIN = "https://api.defer.run"; | ||
export const PATH = "/api/v1/"; | ||
export const TOKEN_ENV_NAME = "DEFER_TOKEN"; | ||
export const FN_EXECUTION_POLLING_INTERVAL_SECS = 2; | ||
export const FN_EXECUTION_POLLING_INTERVAL = 1000; | ||
export const INTERNAL_VERSION = 2; |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { FN_EXECUTION_POLLING_INTERVAL_SECS } from "./constants.js"; | ||
import { FN_EXECUTION_POLLING_INTERVAL } from "./constants.js"; | ||
export function executeBackgroundFunction(fnName, args, fetcher, debug = false) { | ||
@@ -51,10 +51,4 @@ return new Promise((resolve, reject) => { | ||
} | ||
const jitter = (attempt) => Math.floor(Math.random() * | ||
(Math.min(15, Math.pow(FN_EXECUTION_POLLING_INTERVAL_SECS * 2, attempt)) - | ||
0 + | ||
1) + | ||
0); | ||
// TODO(charly): handler error cases | ||
export function poolForExecutionResult(fnName, runId, fetcher, debug = false) { | ||
let attempt = 1; | ||
const getResult = async () => fetcher(`executions/${runId}`, { | ||
@@ -79,7 +73,6 @@ method: "GET", | ||
} | ||
setTimeout(poll, jitter(attempt++)); | ||
setTimeout(poll, FN_EXECUTION_POLLING_INTERVAL); | ||
}; | ||
// initial call | ||
setTimeout(poll, jitter(attempt++)); | ||
poll(); | ||
}); | ||
} |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { DOMAIN, PATH, TOKEN_ENV_NAME } from "./constants.js"; | ||
import { DOMAIN, INTERNAL_VERSION, PATH, TOKEN_ENV_NAME } from "./constants.js"; | ||
import { executeBackgroundFunction, poolForExecutionResult, serializeBackgroundFunctionArguments, } from "./execute.js"; | ||
@@ -35,2 +35,3 @@ import { makeFetcher } from "./fetcher.js"; | ||
ret.__fn = fn; | ||
ret.__version = INTERNAL_VERSION; | ||
return ret; | ||
@@ -49,3 +50,4 @@ }; | ||
ret.__fn = fn; | ||
ret.__version = INTERNAL_VERSION; | ||
return ret; | ||
}; |
{ | ||
"name": "@defer.run/client", | ||
"version": "0.1.0-alpha-20221220161057-7e53b27", | ||
"version": "0.1.0-alpha-20221220162232-f42c41b", | ||
"description": "cua JavaScript client", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
export declare const DOMAIN = "https://api.defer.run"; | ||
export declare const PATH = "/api/v1/"; | ||
export declare const TOKEN_ENV_NAME = "DEFER_TOKEN"; | ||
export declare const FN_EXECUTION_POLLING_INTERVAL_SECS = 2; | ||
export declare const FN_EXECUTION_POLLING_INTERVAL = 1000; | ||
export declare const INTERNAL_VERSION = 2; |
@@ -13,2 +13,3 @@ import { DeferExecuteResponse } from "./execute.js"; | ||
__fn: F; | ||
__version: number; | ||
} | ||
@@ -18,2 +19,3 @@ interface DeferAwaitRetFn<F extends (...args: any | undefined) => Promise<any>> { | ||
__fn: F; | ||
__version: number; | ||
} | ||
@@ -20,0 +22,0 @@ interface Defer { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
19502
354