@io-orkes/conductor-javascript 2.0.0-rc1 → 2.0.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2199 -3
- package/dist/index.d.ts +2199 -3
- package/dist/index.js +431 -409
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +431 -409
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -17
- package/dist/browser.d.mts +0 -13
- package/dist/browser.d.ts +0 -13
- package/dist/browser.js +0 -3764
- package/dist/browser.js.map +0 -1
- package/dist/browser.mjs +0 -3667
- package/dist/browser.mjs.map +0 -1
- package/dist/types-dbfd77fb.d.ts +0 -2200
package/dist/index.js
CHANGED
|
@@ -107,16 +107,9 @@ var LOG_LEVELS = {
|
|
|
107
107
|
ERROR: 60
|
|
108
108
|
};
|
|
109
109
|
var DefaultLogger = class {
|
|
110
|
+
tags;
|
|
111
|
+
level;
|
|
110
112
|
constructor(config = {}) {
|
|
111
|
-
this.info = (...args) => {
|
|
112
|
-
this.log("INFO", ...args);
|
|
113
|
-
};
|
|
114
|
-
this.debug = (...args) => {
|
|
115
|
-
this.log("DEBUG", ...args);
|
|
116
|
-
};
|
|
117
|
-
this.error = (...args) => {
|
|
118
|
-
this.log("ERROR", ...args);
|
|
119
|
-
};
|
|
120
113
|
const { level, tags = [] } = config;
|
|
121
114
|
this.tags = tags;
|
|
122
115
|
if (level && level in LOG_LEVELS) {
|
|
@@ -138,6 +131,15 @@ var DefaultLogger = class {
|
|
|
138
131
|
console.log(name, ...this.tags, ...args);
|
|
139
132
|
}
|
|
140
133
|
}
|
|
134
|
+
info = (...args) => {
|
|
135
|
+
this.log("INFO", ...args);
|
|
136
|
+
};
|
|
137
|
+
debug = (...args) => {
|
|
138
|
+
this.log("DEBUG", ...args);
|
|
139
|
+
};
|
|
140
|
+
error = (...args) => {
|
|
141
|
+
this.log("ERROR", ...args);
|
|
142
|
+
};
|
|
141
143
|
};
|
|
142
144
|
var noopLogger = {
|
|
143
145
|
//eslint-disable-next-line
|
|
@@ -1588,6 +1590,11 @@ var WorkflowResourceService = class {
|
|
|
1588
1590
|
|
|
1589
1591
|
// src/common/open-api/core/ApiError.ts
|
|
1590
1592
|
var ApiError = class extends Error {
|
|
1593
|
+
url;
|
|
1594
|
+
status;
|
|
1595
|
+
statusText;
|
|
1596
|
+
body;
|
|
1597
|
+
request;
|
|
1591
1598
|
constructor(request3, response, message) {
|
|
1592
1599
|
super(message);
|
|
1593
1600
|
this.name = "ApiError";
|
|
@@ -1610,9 +1617,14 @@ var CancelError = class extends Error {
|
|
|
1610
1617
|
}
|
|
1611
1618
|
};
|
|
1612
1619
|
var CancelablePromise = class {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1620
|
+
[Symbol.toStringTag];
|
|
1621
|
+
_isResolved;
|
|
1622
|
+
_isRejected;
|
|
1623
|
+
_isCancelled;
|
|
1624
|
+
_cancelHandlers;
|
|
1625
|
+
_promise;
|
|
1626
|
+
_resolve;
|
|
1627
|
+
_reject;
|
|
1616
1628
|
constructor(executor) {
|
|
1617
1629
|
this._isResolved = false;
|
|
1618
1630
|
this._isRejected = false;
|
|
@@ -2249,6 +2261,18 @@ var HumanTaskResourceService = class {
|
|
|
2249
2261
|
// src/common/open-api/ConductorClient.ts
|
|
2250
2262
|
var defaultRequestHandler = (request3, config, options) => request3(config, options);
|
|
2251
2263
|
var ConductorClient = class {
|
|
2264
|
+
eventResource;
|
|
2265
|
+
healthCheckResource;
|
|
2266
|
+
metadataResource;
|
|
2267
|
+
schedulerResource;
|
|
2268
|
+
taskResource;
|
|
2269
|
+
tokenResource;
|
|
2270
|
+
workflowBulkResource;
|
|
2271
|
+
workflowResource;
|
|
2272
|
+
humanTask;
|
|
2273
|
+
humanTaskResource;
|
|
2274
|
+
request;
|
|
2275
|
+
token;
|
|
2252
2276
|
constructor(config, requestHandler = defaultRequestHandler) {
|
|
2253
2277
|
const resolvedConfig = {
|
|
2254
2278
|
BASE: config?.serverUrl ?? "http://localhost:8080",
|
|
@@ -2302,75 +2326,21 @@ var DEFAULT_BATCH_POLLING_TIMEOUT = 100;
|
|
|
2302
2326
|
|
|
2303
2327
|
// src/task/Poller.ts
|
|
2304
2328
|
var Poller = class {
|
|
2329
|
+
timeoutHandler;
|
|
2330
|
+
pollFunction;
|
|
2331
|
+
performWorkFunction = async () => {
|
|
2332
|
+
};
|
|
2333
|
+
polling = false;
|
|
2334
|
+
_tasksInProcess = 0;
|
|
2335
|
+
_counterAtO = 0;
|
|
2336
|
+
_pollerId = "";
|
|
2337
|
+
options = {
|
|
2338
|
+
pollInterval: DEFAULT_POLL_INTERVAL,
|
|
2339
|
+
concurrency: DEFAULT_CONCURRENCY,
|
|
2340
|
+
warnAtO: DEFAULT_WARN_AT_O
|
|
2341
|
+
};
|
|
2342
|
+
logger = noopLogger;
|
|
2305
2343
|
constructor(pollerId, pollFunction, performWorkFunction, pollerOptions, logger) {
|
|
2306
|
-
this.performWorkFunction = async () => {
|
|
2307
|
-
};
|
|
2308
|
-
this.polling = false;
|
|
2309
|
-
this._tasksInProcess = 0;
|
|
2310
|
-
this._counterAtO = 0;
|
|
2311
|
-
this._pollerId = "";
|
|
2312
|
-
this.options = {
|
|
2313
|
-
pollInterval: DEFAULT_POLL_INTERVAL,
|
|
2314
|
-
concurrency: DEFAULT_CONCURRENCY,
|
|
2315
|
-
warnAtO: DEFAULT_WARN_AT_O
|
|
2316
|
-
};
|
|
2317
|
-
this.logger = noopLogger;
|
|
2318
|
-
/**
|
|
2319
|
-
* Starts polling for work
|
|
2320
|
-
*/
|
|
2321
|
-
this.startPolling = () => {
|
|
2322
|
-
if (this.polling) {
|
|
2323
|
-
throw new Error("Runner is already started");
|
|
2324
|
-
}
|
|
2325
|
-
this._tasksInProcess = 0;
|
|
2326
|
-
this.polling = true;
|
|
2327
|
-
this.poll();
|
|
2328
|
-
};
|
|
2329
|
-
/**
|
|
2330
|
-
* Stops Polling for work
|
|
2331
|
-
*/
|
|
2332
|
-
this.stopPolling = async () => {
|
|
2333
|
-
this.polling = false;
|
|
2334
|
-
clearTimeout(this.timeoutHandler);
|
|
2335
|
-
};
|
|
2336
|
-
this.performWork = async (work) => {
|
|
2337
|
-
await this.performWorkFunction(work);
|
|
2338
|
-
this._tasksInProcess--;
|
|
2339
|
-
};
|
|
2340
|
-
this.poll = async () => {
|
|
2341
|
-
while (this.isPolling) {
|
|
2342
|
-
try {
|
|
2343
|
-
const count = Math.max(
|
|
2344
|
-
0,
|
|
2345
|
-
this.options.concurrency - this._tasksInProcess
|
|
2346
|
-
);
|
|
2347
|
-
if (count === 0) {
|
|
2348
|
-
this.logger.debug(
|
|
2349
|
-
"Max in process reached, Will skip polling for " + this._pollerId
|
|
2350
|
-
);
|
|
2351
|
-
this._counterAtO++;
|
|
2352
|
-
if (this._counterAtO > (this.options.warnAtO ?? 100)) {
|
|
2353
|
-
this.logger.info(
|
|
2354
|
-
`Not polling anything because in process tasks is maxed as concurrency level. ${this._pollerId}`
|
|
2355
|
-
);
|
|
2356
|
-
}
|
|
2357
|
-
} else {
|
|
2358
|
-
this._counterAtO = 0;
|
|
2359
|
-
const tasksResult = await this.pollFunction(count);
|
|
2360
|
-
this._tasksInProcess = this._tasksInProcess + (tasksResult ?? []).length;
|
|
2361
|
-
tasksResult.forEach(this.performWork);
|
|
2362
|
-
}
|
|
2363
|
-
} catch (e) {
|
|
2364
|
-
this.logger.error(`Error polling for tasks: ${e.message}`, e);
|
|
2365
|
-
}
|
|
2366
|
-
await new Promise(
|
|
2367
|
-
(r) => this.isPolling ? this.timeoutHandler = setTimeout(
|
|
2368
|
-
() => r(true),
|
|
2369
|
-
this.options.pollInterval
|
|
2370
|
-
) : r(true)
|
|
2371
|
-
);
|
|
2372
|
-
}
|
|
2373
|
-
};
|
|
2374
2344
|
this._pollerId = pollerId;
|
|
2375
2345
|
this.pollFunction = pollFunction;
|
|
2376
2346
|
this.performWorkFunction = performWorkFunction;
|
|
@@ -2383,10 +2353,66 @@ var Poller = class {
|
|
|
2383
2353
|
get tasksInProcess() {
|
|
2384
2354
|
return this._tasksInProcess;
|
|
2385
2355
|
}
|
|
2356
|
+
/**
|
|
2357
|
+
* Starts polling for work
|
|
2358
|
+
*/
|
|
2359
|
+
startPolling = () => {
|
|
2360
|
+
if (this.polling) {
|
|
2361
|
+
throw new Error("Runner is already started");
|
|
2362
|
+
}
|
|
2363
|
+
this._tasksInProcess = 0;
|
|
2364
|
+
this.polling = true;
|
|
2365
|
+
this.poll();
|
|
2366
|
+
};
|
|
2367
|
+
/**
|
|
2368
|
+
* Stops Polling for work
|
|
2369
|
+
*/
|
|
2370
|
+
stopPolling = async () => {
|
|
2371
|
+
this.polling = false;
|
|
2372
|
+
clearTimeout(this.timeoutHandler);
|
|
2373
|
+
};
|
|
2374
|
+
performWork = async (work) => {
|
|
2375
|
+
await this.performWorkFunction(work);
|
|
2376
|
+
this._tasksInProcess--;
|
|
2377
|
+
};
|
|
2386
2378
|
updateOptions(options) {
|
|
2387
2379
|
const newOptions = { ...this.options, ...options };
|
|
2388
2380
|
this.options = newOptions;
|
|
2389
2381
|
}
|
|
2382
|
+
poll = async () => {
|
|
2383
|
+
while (this.isPolling) {
|
|
2384
|
+
try {
|
|
2385
|
+
const count = Math.max(
|
|
2386
|
+
0,
|
|
2387
|
+
this.options.concurrency - this._tasksInProcess
|
|
2388
|
+
);
|
|
2389
|
+
if (count === 0) {
|
|
2390
|
+
this.logger.debug(
|
|
2391
|
+
"Max in process reached, Will skip polling for " + this._pollerId
|
|
2392
|
+
);
|
|
2393
|
+
this._counterAtO++;
|
|
2394
|
+
if (this._counterAtO > (this.options.warnAtO ?? 100)) {
|
|
2395
|
+
this.logger.info(
|
|
2396
|
+
`Not polling anything because in process tasks is maxed as concurrency level. ${this._pollerId}`
|
|
2397
|
+
);
|
|
2398
|
+
}
|
|
2399
|
+
} else {
|
|
2400
|
+
this._counterAtO = 0;
|
|
2401
|
+
const tasksResult = await this.pollFunction(count);
|
|
2402
|
+
this._tasksInProcess = this._tasksInProcess + (tasksResult ?? []).length;
|
|
2403
|
+
tasksResult.forEach(this.performWork);
|
|
2404
|
+
}
|
|
2405
|
+
} catch (e) {
|
|
2406
|
+
this.logger.error(`Error polling for tasks: ${e.message}`, e);
|
|
2407
|
+
}
|
|
2408
|
+
await new Promise(
|
|
2409
|
+
(r) => this.isPolling ? this.timeoutHandler = setTimeout(
|
|
2410
|
+
() => r(true),
|
|
2411
|
+
this.options.pollInterval
|
|
2412
|
+
) : r(true)
|
|
2413
|
+
);
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2390
2416
|
};
|
|
2391
2417
|
|
|
2392
2418
|
// src/task/helpers.ts
|
|
@@ -2411,6 +2437,12 @@ var defaultRunnerOptions = {
|
|
|
2411
2437
|
batchPollingTimeout: DEFAULT_BATCH_POLLING_TIMEOUT
|
|
2412
2438
|
};
|
|
2413
2439
|
var TaskRunner = class {
|
|
2440
|
+
taskResource;
|
|
2441
|
+
worker;
|
|
2442
|
+
logger;
|
|
2443
|
+
options;
|
|
2444
|
+
errorHandler;
|
|
2445
|
+
poller;
|
|
2414
2446
|
constructor({
|
|
2415
2447
|
worker,
|
|
2416
2448
|
taskResource,
|
|
@@ -2418,91 +2450,6 @@ var TaskRunner = class {
|
|
|
2418
2450
|
logger = noopLogger,
|
|
2419
2451
|
onError: errorHandler = noopErrorHandler
|
|
2420
2452
|
}) {
|
|
2421
|
-
/**
|
|
2422
|
-
* Starts polling for work
|
|
2423
|
-
*/
|
|
2424
|
-
this.startPolling = () => {
|
|
2425
|
-
this.poller.startPolling();
|
|
2426
|
-
this.logger.info(
|
|
2427
|
-
`TaskWorker ${this.worker.taskDefName} initialized with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
|
|
2428
|
-
);
|
|
2429
|
-
};
|
|
2430
|
-
/**
|
|
2431
|
-
* Stops Polling for work
|
|
2432
|
-
*/
|
|
2433
|
-
this.stopPolling = async () => {
|
|
2434
|
-
await this.poller.stopPolling();
|
|
2435
|
-
};
|
|
2436
|
-
this.batchPoll = async (count) => {
|
|
2437
|
-
const { workerID } = this.options;
|
|
2438
|
-
const tasks = await this.taskResource.batchPoll(
|
|
2439
|
-
this.worker.taskDefName,
|
|
2440
|
-
workerID,
|
|
2441
|
-
this.worker.domain ?? this.options.domain,
|
|
2442
|
-
count,
|
|
2443
|
-
this.options.batchPollingTimeout ?? 100
|
|
2444
|
-
// default batch poll defined in the method
|
|
2445
|
-
);
|
|
2446
|
-
return tasks;
|
|
2447
|
-
};
|
|
2448
|
-
this.updateTaskWithRetry = async (task, taskResult) => {
|
|
2449
|
-
const { workerID } = this.options;
|
|
2450
|
-
let retryCount = 0;
|
|
2451
|
-
while (retryCount < MAX_RETRIES) {
|
|
2452
|
-
try {
|
|
2453
|
-
await this.taskResource.updateTask1({
|
|
2454
|
-
...taskResult,
|
|
2455
|
-
workerId: workerID
|
|
2456
|
-
});
|
|
2457
|
-
return;
|
|
2458
|
-
} catch (error) {
|
|
2459
|
-
this.errorHandler(error, task);
|
|
2460
|
-
this.logger.error(
|
|
2461
|
-
`Error updating task ${taskResult.taskId} on retry ${retryCount}`,
|
|
2462
|
-
error
|
|
2463
|
-
);
|
|
2464
|
-
retryCount++;
|
|
2465
|
-
await new Promise((r) => setTimeout(() => r(true), retryCount * 10));
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
this.logger.error(
|
|
2469
|
-
`Unable to update task ${taskResult.taskId} after ${retryCount} retries`
|
|
2470
|
-
);
|
|
2471
|
-
};
|
|
2472
|
-
this.executeTask = async (task) => {
|
|
2473
|
-
try {
|
|
2474
|
-
const result = await this.worker.execute(task);
|
|
2475
|
-
await this.updateTaskWithRetry(task, {
|
|
2476
|
-
...result,
|
|
2477
|
-
workflowInstanceId: task.workflowInstanceId,
|
|
2478
|
-
taskId: task.taskId
|
|
2479
|
-
});
|
|
2480
|
-
this.logger.debug(`Task has executed successfully ${task.taskId}`);
|
|
2481
|
-
} catch (error) {
|
|
2482
|
-
await this.updateTaskWithRetry(task, {
|
|
2483
|
-
workflowInstanceId: task.workflowInstanceId,
|
|
2484
|
-
taskId: task.taskId,
|
|
2485
|
-
reasonForIncompletion: error?.message ?? DEFAULT_ERROR_MESSAGE,
|
|
2486
|
-
status: "FAILED",
|
|
2487
|
-
outputData: {}
|
|
2488
|
-
});
|
|
2489
|
-
this.errorHandler(error, task);
|
|
2490
|
-
this.logger.error(`Error executing ${task.taskId}`, error);
|
|
2491
|
-
}
|
|
2492
|
-
};
|
|
2493
|
-
this.handleUnknownError = (unknownError) => {
|
|
2494
|
-
let message = "";
|
|
2495
|
-
let stack = "";
|
|
2496
|
-
if (unknownError.stack) {
|
|
2497
|
-
stack = unknownError.stack;
|
|
2498
|
-
}
|
|
2499
|
-
if (unknownError.message) {
|
|
2500
|
-
message = unknownError.message;
|
|
2501
|
-
}
|
|
2502
|
-
this.logger.error(
|
|
2503
|
-
`Error for ${this.worker.taskDefName}: error: ${message}, stack: ${stack}`
|
|
2504
|
-
);
|
|
2505
|
-
};
|
|
2506
2453
|
this.taskResource = taskResource;
|
|
2507
2454
|
this.logger = logger;
|
|
2508
2455
|
this.worker = worker;
|
|
@@ -2522,6 +2469,21 @@ var TaskRunner = class {
|
|
|
2522
2469
|
get isPolling() {
|
|
2523
2470
|
return this.poller.isPolling;
|
|
2524
2471
|
}
|
|
2472
|
+
/**
|
|
2473
|
+
* Starts polling for work
|
|
2474
|
+
*/
|
|
2475
|
+
startPolling = () => {
|
|
2476
|
+
this.poller.startPolling();
|
|
2477
|
+
this.logger.info(
|
|
2478
|
+
`TaskWorker ${this.worker.taskDefName} initialized with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
|
|
2479
|
+
);
|
|
2480
|
+
};
|
|
2481
|
+
/**
|
|
2482
|
+
* Stops Polling for work
|
|
2483
|
+
*/
|
|
2484
|
+
stopPolling = async () => {
|
|
2485
|
+
await this.poller.stopPolling();
|
|
2486
|
+
};
|
|
2525
2487
|
updateOptions(options) {
|
|
2526
2488
|
const newOptions = { ...this.options, ...options };
|
|
2527
2489
|
const isOptionsUpdated = !optionEquals(this.options, newOptions);
|
|
@@ -2539,6 +2501,76 @@ var TaskRunner = class {
|
|
|
2539
2501
|
get getOptions() {
|
|
2540
2502
|
return this.options;
|
|
2541
2503
|
}
|
|
2504
|
+
batchPoll = async (count) => {
|
|
2505
|
+
const { workerID } = this.options;
|
|
2506
|
+
const tasks = await this.taskResource.batchPoll(
|
|
2507
|
+
this.worker.taskDefName,
|
|
2508
|
+
workerID,
|
|
2509
|
+
this.worker.domain ?? this.options.domain,
|
|
2510
|
+
count,
|
|
2511
|
+
this.options.batchPollingTimeout ?? 100
|
|
2512
|
+
// default batch poll defined in the method
|
|
2513
|
+
);
|
|
2514
|
+
return tasks;
|
|
2515
|
+
};
|
|
2516
|
+
updateTaskWithRetry = async (task, taskResult) => {
|
|
2517
|
+
const { workerID } = this.options;
|
|
2518
|
+
let retryCount = 0;
|
|
2519
|
+
while (retryCount < MAX_RETRIES) {
|
|
2520
|
+
try {
|
|
2521
|
+
await this.taskResource.updateTask1({
|
|
2522
|
+
...taskResult,
|
|
2523
|
+
workerId: workerID
|
|
2524
|
+
});
|
|
2525
|
+
return;
|
|
2526
|
+
} catch (error) {
|
|
2527
|
+
this.errorHandler(error, task);
|
|
2528
|
+
this.logger.error(
|
|
2529
|
+
`Error updating task ${taskResult.taskId} on retry ${retryCount}`,
|
|
2530
|
+
error
|
|
2531
|
+
);
|
|
2532
|
+
retryCount++;
|
|
2533
|
+
await new Promise((r) => setTimeout(() => r(true), retryCount * 10));
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
this.logger.error(
|
|
2537
|
+
`Unable to update task ${taskResult.taskId} after ${retryCount} retries`
|
|
2538
|
+
);
|
|
2539
|
+
};
|
|
2540
|
+
executeTask = async (task) => {
|
|
2541
|
+
try {
|
|
2542
|
+
const result = await this.worker.execute(task);
|
|
2543
|
+
await this.updateTaskWithRetry(task, {
|
|
2544
|
+
...result,
|
|
2545
|
+
workflowInstanceId: task.workflowInstanceId,
|
|
2546
|
+
taskId: task.taskId
|
|
2547
|
+
});
|
|
2548
|
+
this.logger.debug(`Task has executed successfully ${task.taskId}`);
|
|
2549
|
+
} catch (error) {
|
|
2550
|
+
await this.updateTaskWithRetry(task, {
|
|
2551
|
+
workflowInstanceId: task.workflowInstanceId,
|
|
2552
|
+
taskId: task.taskId,
|
|
2553
|
+
reasonForIncompletion: error?.message ?? DEFAULT_ERROR_MESSAGE,
|
|
2554
|
+
status: "FAILED",
|
|
2555
|
+
outputData: {}
|
|
2556
|
+
});
|
|
2557
|
+
this.errorHandler(error, task);
|
|
2558
|
+
this.logger.error(`Error executing ${task.taskId}`, error);
|
|
2559
|
+
}
|
|
2560
|
+
};
|
|
2561
|
+
handleUnknownError = (unknownError) => {
|
|
2562
|
+
let message = "";
|
|
2563
|
+
let stack = "";
|
|
2564
|
+
if (unknownError.stack) {
|
|
2565
|
+
stack = unknownError.stack;
|
|
2566
|
+
}
|
|
2567
|
+
if (unknownError.message) {
|
|
2568
|
+
message = unknownError.message;
|
|
2569
|
+
}
|
|
2570
|
+
this.logger.error(
|
|
2571
|
+
`Error for ${this.worker.taskDefName}: error: ${message}, stack: ${stack}`
|
|
2572
|
+
);
|
|
2573
|
+
};
|
|
2542
2574
|
};
|
|
2543
2575
|
|
|
2544
2576
|
// src/task/TaskManager.ts
|
|
@@ -2554,84 +2586,14 @@ function workerId(options) {
|
|
|
2554
2586
|
return options.workerID ?? import_os.default.hostname();
|
|
2555
2587
|
}
|
|
2556
2588
|
var TaskManager = class {
|
|
2589
|
+
workerRunners = /* @__PURE__ */ new Map();
|
|
2590
|
+
client;
|
|
2591
|
+
logger;
|
|
2592
|
+
errorHandler;
|
|
2593
|
+
workers;
|
|
2594
|
+
options;
|
|
2595
|
+
polling = false;
|
|
2557
2596
|
constructor(client, workers, config = {}) {
|
|
2558
|
-
this.workerRunners = /* @__PURE__ */ new Map();
|
|
2559
|
-
this.polling = false;
|
|
2560
|
-
this.workerManagerWorkerOptions = (worker) => {
|
|
2561
|
-
return {
|
|
2562
|
-
...this.options,
|
|
2563
|
-
concurrency: worker.concurrency ?? this.options.concurrency,
|
|
2564
|
-
pollInterval: worker.pollInterval ?? this.options.pollInterval,
|
|
2565
|
-
domain: worker.domain ?? this.options.domain
|
|
2566
|
-
};
|
|
2567
|
-
};
|
|
2568
|
-
this.updatePollingOptionForWorker = (workerTaskDefName, options) => {
|
|
2569
|
-
const maybeRunner = this.workerRunners.get(workerTaskDefName);
|
|
2570
|
-
if (maybeRunner != null) {
|
|
2571
|
-
maybeRunner.updateOptions(options);
|
|
2572
|
-
} else {
|
|
2573
|
-
this.logger.info(
|
|
2574
|
-
`No runner found for worker with taskDefName: ${workerTaskDefName}`
|
|
2575
|
-
);
|
|
2576
|
-
}
|
|
2577
|
-
};
|
|
2578
|
-
/**
|
|
2579
|
-
* new options will get merged to existing options
|
|
2580
|
-
* @param options new options to update polling options
|
|
2581
|
-
*/
|
|
2582
|
-
this.updatePollingOptions = (options) => {
|
|
2583
|
-
this.workers.forEach((worker) => {
|
|
2584
|
-
const newOptions = {
|
|
2585
|
-
...this.workerManagerWorkerOptions(worker),
|
|
2586
|
-
...options
|
|
2587
|
-
};
|
|
2588
|
-
this.updatePollingOptionForWorker(worker.taskDefName, newOptions);
|
|
2589
|
-
});
|
|
2590
|
-
this.options.concurrency = options.concurrency ?? this.options.concurrency;
|
|
2591
|
-
this.options.pollInterval = options.pollInterval ?? this.options.pollInterval;
|
|
2592
|
-
};
|
|
2593
|
-
this.sanityCheck = () => {
|
|
2594
|
-
if (this.workers.length === 0) {
|
|
2595
|
-
throw new Error("No workers supplied to TaskManager");
|
|
2596
|
-
}
|
|
2597
|
-
const workerIDs = /* @__PURE__ */ new Set();
|
|
2598
|
-
for (const item of this.workers) {
|
|
2599
|
-
if (workerIDs.has(item.taskDefName)) {
|
|
2600
|
-
throw new Error(`Duplicate worker taskDefName: ${item.taskDefName}`);
|
|
2601
|
-
}
|
|
2602
|
-
workerIDs.add(item.taskDefName);
|
|
2603
|
-
}
|
|
2604
|
-
};
|
|
2605
|
-
/**
|
|
2606
|
-
* Start polling for tasks
|
|
2607
|
-
*/
|
|
2608
|
-
this.startPolling = () => {
|
|
2609
|
-
this.sanityCheck();
|
|
2610
|
-
this.workers.forEach((worker) => {
|
|
2611
|
-
const options = this.workerManagerWorkerOptions(worker);
|
|
2612
|
-
const runner = new TaskRunner({
|
|
2613
|
-
worker,
|
|
2614
|
-
options,
|
|
2615
|
-
taskResource: this.client.taskResource,
|
|
2616
|
-
logger: this.logger,
|
|
2617
|
-
onError: this.errorHandler
|
|
2618
|
-
});
|
|
2619
|
-
runner.startPolling();
|
|
2620
|
-
this.workerRunners.set(worker.taskDefName, runner);
|
|
2621
|
-
});
|
|
2622
|
-
this.polling = true;
|
|
2623
|
-
};
|
|
2624
|
-
/**
|
|
2625
|
-
* Stops polling for tasks
|
|
2626
|
-
*/
|
|
2627
|
-
this.stopPolling = async () => {
|
|
2628
|
-
for (const [workerTaskDefName, runner] of this.workerRunners) {
|
|
2629
|
-
this.logger.debug(`Stopping taskDefName=${workerTaskDefName}`);
|
|
2630
|
-
await runner.stopPolling();
|
|
2631
|
-
this.workerRunners.delete(workerTaskDefName);
|
|
2632
|
-
}
|
|
2633
|
-
this.polling = false;
|
|
2634
|
-
};
|
|
2635
2597
|
if (!workers) {
|
|
2636
2598
|
throw new Error(
|
|
2637
2599
|
"No workers supplied to TaskManager. Please pass an array of workers."
|
|
@@ -2648,13 +2610,90 @@ var TaskManager = class {
|
|
|
2648
2610
|
workerID: workerId(providedOptions)
|
|
2649
2611
|
};
|
|
2650
2612
|
}
|
|
2613
|
+
workerManagerWorkerOptions = (worker) => {
|
|
2614
|
+
return {
|
|
2615
|
+
...this.options,
|
|
2616
|
+
concurrency: worker.concurrency ?? this.options.concurrency,
|
|
2617
|
+
pollInterval: worker.pollInterval ?? this.options.pollInterval,
|
|
2618
|
+
domain: worker.domain ?? this.options.domain
|
|
2619
|
+
};
|
|
2620
|
+
};
|
|
2651
2621
|
get isPolling() {
|
|
2652
2622
|
return this.polling;
|
|
2653
2623
|
}
|
|
2624
|
+
updatePollingOptionForWorker = (workerTaskDefName, options) => {
|
|
2625
|
+
const maybeRunner = this.workerRunners.get(workerTaskDefName);
|
|
2626
|
+
if (maybeRunner != null) {
|
|
2627
|
+
maybeRunner.updateOptions(options);
|
|
2628
|
+
} else {
|
|
2629
|
+
this.logger.info(
|
|
2630
|
+
`No runner found for worker with taskDefName: ${workerTaskDefName}`
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
};
|
|
2634
|
+
/**
|
|
2635
|
+
* new options will get merged to existing options
|
|
2636
|
+
* @param options new options to update polling options
|
|
2637
|
+
*/
|
|
2638
|
+
updatePollingOptions = (options) => {
|
|
2639
|
+
this.workers.forEach((worker) => {
|
|
2640
|
+
const newOptions = {
|
|
2641
|
+
...this.workerManagerWorkerOptions(worker),
|
|
2642
|
+
...options
|
|
2643
|
+
};
|
|
2644
|
+
this.updatePollingOptionForWorker(worker.taskDefName, newOptions);
|
|
2645
|
+
});
|
|
2646
|
+
this.options.concurrency = options.concurrency ?? this.options.concurrency;
|
|
2647
|
+
this.options.pollInterval = options.pollInterval ?? this.options.pollInterval;
|
|
2648
|
+
};
|
|
2649
|
+
sanityCheck = () => {
|
|
2650
|
+
if (this.workers.length === 0) {
|
|
2651
|
+
throw new Error("No workers supplied to TaskManager");
|
|
2652
|
+
}
|
|
2653
|
+
const workerIDs = /* @__PURE__ */ new Set();
|
|
2654
|
+
for (const item of this.workers) {
|
|
2655
|
+
if (workerIDs.has(item.taskDefName)) {
|
|
2656
|
+
throw new Error(`Duplicate worker taskDefName: ${item.taskDefName}`);
|
|
2657
|
+
}
|
|
2658
|
+
workerIDs.add(item.taskDefName);
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
/**
|
|
2662
|
+
* Start polling for tasks
|
|
2663
|
+
*/
|
|
2664
|
+
startPolling = () => {
|
|
2665
|
+
this.sanityCheck();
|
|
2666
|
+
this.workers.forEach((worker) => {
|
|
2667
|
+
const options = this.workerManagerWorkerOptions(worker);
|
|
2668
|
+
const runner = new TaskRunner({
|
|
2669
|
+
worker,
|
|
2670
|
+
options,
|
|
2671
|
+
taskResource: this.client.taskResource,
|
|
2672
|
+
logger: this.logger,
|
|
2673
|
+
onError: this.errorHandler
|
|
2674
|
+
});
|
|
2675
|
+
runner.startPolling();
|
|
2676
|
+
this.workerRunners.set(worker.taskDefName, runner);
|
|
2677
|
+
});
|
|
2678
|
+
this.polling = true;
|
|
2679
|
+
};
|
|
2680
|
+
/**
|
|
2681
|
+
* Stops polling for tasks
|
|
2682
|
+
*/
|
|
2683
|
+
stopPolling = async () => {
|
|
2684
|
+
for (const [workerTaskDefName, runner] of this.workerRunners) {
|
|
2685
|
+
this.logger.debug(`Stopping taskDefName=${workerTaskDefName}`);
|
|
2686
|
+
await runner.stopPolling();
|
|
2687
|
+
this.workerRunners.delete(workerTaskDefName);
|
|
2688
|
+
}
|
|
2689
|
+
this.polling = false;
|
|
2690
|
+
};
|
|
2654
2691
|
};
|
|
2655
2692
|
|
|
2656
2693
|
// src/core/types.ts
|
|
2657
2694
|
var ConductorError = class extends Error {
|
|
2695
|
+
_trace;
|
|
2696
|
+
__proto__;
|
|
2658
2697
|
constructor(message, innerError) {
|
|
2659
2698
|
super(message);
|
|
2660
2699
|
this._trace = innerError;
|
|
@@ -2689,6 +2728,7 @@ function reverseFind(array, predicate) {
|
|
|
2689
2728
|
var RETRY_TIME_IN_MILLISECONDS = 1e4;
|
|
2690
2729
|
var completedTaskMatchingType = (taskType) => (task) => task.status === "COMPLETED" && task.taskType === taskType;
|
|
2691
2730
|
var WorkflowExecutor = class {
|
|
2731
|
+
_client;
|
|
2692
2732
|
constructor(client) {
|
|
2693
2733
|
this._client = client;
|
|
2694
2734
|
}
|
|
@@ -2994,6 +3034,7 @@ var EMPTY_SEARCH = {
|
|
|
2994
3034
|
};
|
|
2995
3035
|
var DEFAULT_POLL_INTERVAL2 = { pollInterval: 100, maxPollTimes: 20 };
|
|
2996
3036
|
var HumanExecutor = class {
|
|
3037
|
+
_client;
|
|
2997
3038
|
constructor(client) {
|
|
2998
3039
|
this._client = client;
|
|
2999
3040
|
}
|
|
@@ -3638,105 +3679,73 @@ var workflow = (name, tasks) => ({
|
|
|
3638
3679
|
timeoutSeconds: 0
|
|
3639
3680
|
});
|
|
3640
3681
|
|
|
3641
|
-
// src/orkes/
|
|
3642
|
-
var
|
|
3643
|
-
var
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
try {
|
|
3649
|
-
const addresses = await resolver(host);
|
|
3650
|
-
if (addresses.length > 0)
|
|
3651
|
-
return addresses[0];
|
|
3652
|
-
} catch (e) {
|
|
3653
|
-
logger.error("Could not resolve host: " + host + " error: " + e);
|
|
3654
|
-
}
|
|
3655
|
-
return void 0;
|
|
3656
|
-
};
|
|
3657
|
-
|
|
3658
|
-
// src/orkes/request/fetchCatchDns/DnsCache.ts
|
|
3659
|
-
var DnsCacheResolver = class {
|
|
3660
|
-
constructor({ initialCache = /* @__PURE__ */ new Map() } = {}) {
|
|
3661
|
-
this._cache = /* @__PURE__ */ new Map();
|
|
3662
|
-
this._cache = initialCache;
|
|
3682
|
+
// src/orkes/BaseOrkesConductorClient.ts
|
|
3683
|
+
var defaultRequestHandler2 = (request3, config, options) => request3(config, options);
|
|
3684
|
+
var REFRESH_TOKEN_IN_MILLISECONDS = 30 * 60 * 1e3;
|
|
3685
|
+
var AuthConductorClient = class extends ConductorClient {
|
|
3686
|
+
intervalId;
|
|
3687
|
+
constructor(config, requestHandler = defaultRequestHandler2) {
|
|
3688
|
+
super(config, requestHandler);
|
|
3663
3689
|
}
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
if (ip != void 0) {
|
|
3671
|
-
this._cache.set(host, ip);
|
|
3690
|
+
/**
|
|
3691
|
+
* Stops the interval that refreshes the token
|
|
3692
|
+
*/
|
|
3693
|
+
stop() {
|
|
3694
|
+
if (this.intervalId != null) {
|
|
3695
|
+
clearInterval(this.intervalId);
|
|
3672
3696
|
}
|
|
3673
|
-
return ip;
|
|
3674
3697
|
}
|
|
3675
|
-
clearCache() {
|
|
3676
|
-
this._cache.clear();
|
|
3677
|
-
}
|
|
3678
|
-
removeCache(host) {
|
|
3679
|
-
this._cache.delete(host);
|
|
3680
|
-
}
|
|
3681
|
-
get cache() {
|
|
3682
|
-
return this._cache;
|
|
3683
|
-
}
|
|
3684
|
-
};
|
|
3685
|
-
|
|
3686
|
-
// src/orkes/request/fetchCatchDns/fetchCatchDns.ts
|
|
3687
|
-
var import_net = require("net");
|
|
3688
|
-
var isEmpty = (value) => {
|
|
3689
|
-
return value === void 0 || value.trim().length === 0;
|
|
3690
3698
|
};
|
|
3691
|
-
var
|
|
3692
|
-
const
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
};
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
};
|
|
3727
|
-
try {
|
|
3728
|
-
const res = await fetch3(target.toString(), optionsOverride);
|
|
3729
|
-
return res;
|
|
3730
|
-
} catch (e) {
|
|
3731
|
-
if (e && e?.code === "ETIMEDOUT") {
|
|
3732
|
-
dnsCache.removeCache(hostname);
|
|
3699
|
+
var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHandler2) => {
|
|
3700
|
+
const requestTokenForKeySecret = (keyId, keySecret, tokenUrl) => fetchFn(tokenUrl, {
|
|
3701
|
+
headers: {
|
|
3702
|
+
"Content-Type": "application/json",
|
|
3703
|
+
Accept: "application/json"
|
|
3704
|
+
},
|
|
3705
|
+
body: JSON.stringify({ keyId, keySecret }),
|
|
3706
|
+
method: "POST"
|
|
3707
|
+
});
|
|
3708
|
+
return async (config, requestHandler = baseRequestHandler) => {
|
|
3709
|
+
if (config?.keySecret != null && config?.keyId != null) {
|
|
3710
|
+
const {
|
|
3711
|
+
serverUrl,
|
|
3712
|
+
keyId,
|
|
3713
|
+
keySecret,
|
|
3714
|
+
refreshTokenInterval = REFRESH_TOKEN_IN_MILLISECONDS
|
|
3715
|
+
} = config;
|
|
3716
|
+
const tokenUrl = `${serverUrl}/token`;
|
|
3717
|
+
const res = await requestTokenForKeySecret(keyId, keySecret, tokenUrl);
|
|
3718
|
+
const { token } = await res.json();
|
|
3719
|
+
const conductorClientInstance = new AuthConductorClient(
|
|
3720
|
+
{ ...config, TOKEN: token },
|
|
3721
|
+
requestHandler
|
|
3722
|
+
);
|
|
3723
|
+
if (token != null && refreshTokenInterval > 0) {
|
|
3724
|
+
const intervalId = setInterval(async () => {
|
|
3725
|
+
const res2 = await requestTokenForKeySecret(
|
|
3726
|
+
keyId,
|
|
3727
|
+
keySecret,
|
|
3728
|
+
tokenUrl
|
|
3729
|
+
);
|
|
3730
|
+
const { token: token2 } = await res2.json();
|
|
3731
|
+
conductorClientInstance.token = token2;
|
|
3732
|
+
}, refreshTokenInterval);
|
|
3733
|
+
conductorClientInstance.intervalId = intervalId;
|
|
3733
3734
|
}
|
|
3734
|
-
|
|
3735
|
+
return conductorClientInstance;
|
|
3736
|
+
} else {
|
|
3737
|
+
return new ConductorClient(config, requestHandler);
|
|
3735
3738
|
}
|
|
3736
3739
|
};
|
|
3737
|
-
return fetchWithDns;
|
|
3738
3740
|
};
|
|
3739
3741
|
|
|
3742
|
+
// src/orkes/OrkesConductorClient.ts
|
|
3743
|
+
var defaultRequestHandler3 = (request3, config, options) => request3(config, options);
|
|
3744
|
+
var orkesConductorClient = baseOrkesConductorClient(
|
|
3745
|
+
fetch,
|
|
3746
|
+
defaultRequestHandler3
|
|
3747
|
+
);
|
|
3748
|
+
|
|
3740
3749
|
// src/orkes/request/request.ts
|
|
3741
3750
|
var isDefined2 = (value) => {
|
|
3742
3751
|
return value !== void 0 && value !== null;
|
|
@@ -3972,91 +3981,104 @@ var request2 = (config, options, fetchFn = fetch) => {
|
|
|
3972
3981
|
});
|
|
3973
3982
|
};
|
|
3974
3983
|
|
|
3975
|
-
// src/orkes/
|
|
3976
|
-
var
|
|
3977
|
-
var
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3984
|
+
// src/orkes/request/fetchCatchDns/DnsResolver.ts
|
|
3985
|
+
var import_dns = require("dns");
|
|
3986
|
+
var DEFAULT_OPTIONS = {
|
|
3987
|
+
logger: noopLogger,
|
|
3988
|
+
resolver: import_dns.promises.resolve4
|
|
3989
|
+
};
|
|
3990
|
+
var dnsResolver = async (host, { resolver = import_dns.promises.resolve4, logger = console } = DEFAULT_OPTIONS) => {
|
|
3991
|
+
try {
|
|
3992
|
+
const addresses = await resolver(host);
|
|
3993
|
+
if (addresses.length > 0)
|
|
3994
|
+
return addresses[0];
|
|
3995
|
+
} catch (e) {
|
|
3996
|
+
logger.error("Could not resolve host: " + host + " error: " + e);
|
|
3981
3997
|
}
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3998
|
+
return void 0;
|
|
3999
|
+
};
|
|
4000
|
+
|
|
4001
|
+
// src/orkes/request/fetchCatchDns/DnsCache.ts
|
|
4002
|
+
var DnsCacheResolver = class {
|
|
4003
|
+
_cache = /* @__PURE__ */ new Map();
|
|
4004
|
+
constructor({ initialCache = /* @__PURE__ */ new Map() } = {}) {
|
|
4005
|
+
this._cache = initialCache;
|
|
4006
|
+
}
|
|
4007
|
+
async resolve(host) {
|
|
4008
|
+
const cachedIp = this._cache.get(host);
|
|
4009
|
+
if (cachedIp) {
|
|
4010
|
+
return cachedIp;
|
|
3988
4011
|
}
|
|
4012
|
+
const ip = await dnsResolver(host);
|
|
4013
|
+
if (ip != void 0) {
|
|
4014
|
+
this._cache.set(host, ip);
|
|
4015
|
+
}
|
|
4016
|
+
return ip;
|
|
4017
|
+
}
|
|
4018
|
+
clearCache() {
|
|
4019
|
+
this._cache.clear();
|
|
4020
|
+
}
|
|
4021
|
+
removeCache(host) {
|
|
4022
|
+
this._cache.delete(host);
|
|
4023
|
+
}
|
|
4024
|
+
get cache() {
|
|
4025
|
+
return this._cache;
|
|
3989
4026
|
}
|
|
3990
4027
|
};
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
}
|
|
4000
|
-
return
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
);
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4028
|
+
|
|
4029
|
+
// src/orkes/request/fetchCatchDns/fetchCatchDns.ts
|
|
4030
|
+
var import_net = require("net");
|
|
4031
|
+
var isEmpty = (value) => {
|
|
4032
|
+
return value === void 0 || value.trim().length === 0;
|
|
4033
|
+
};
|
|
4034
|
+
var toMaybeUrl = (originalUrl, modifiedParams) => {
|
|
4035
|
+
const urlToHit = new URL(originalUrl.toString());
|
|
4036
|
+
urlToHit.host = isEmpty(modifiedParams.port) ? `${modifiedParams.host}:${modifiedParams.port}` : modifiedParams.host;
|
|
4037
|
+
return urlToHit;
|
|
4038
|
+
};
|
|
4039
|
+
var DEFAULT_OPTIONS2 = {
|
|
4040
|
+
dnsCache: new DnsCacheResolver(),
|
|
4041
|
+
headerFactory: (headers) => new Headers(headers || {})
|
|
4042
|
+
};
|
|
4043
|
+
var fetchCatchDns = (fetch2, {
|
|
4044
|
+
dnsCache = new DnsCacheResolver(),
|
|
4045
|
+
headerFactory = (headers) => new Headers(headers || {})
|
|
4046
|
+
} = DEFAULT_OPTIONS2) => {
|
|
4047
|
+
const fetchWithDns = async (input, options) => {
|
|
4048
|
+
const parsedUrl = new URL(input.toString());
|
|
4049
|
+
const { hostname, host, port } = parsedUrl;
|
|
4050
|
+
if ((0, import_net.isIP)(hostname)) {
|
|
4051
|
+
return await fetch2(input, options);
|
|
4052
|
+
}
|
|
4053
|
+
const maybeTargetIp = await dnsCache.resolve(hostname);
|
|
4054
|
+
if (isEmpty(maybeTargetIp)) {
|
|
4055
|
+
return await fetch2(input, options);
|
|
4056
|
+
}
|
|
4057
|
+
const target = toMaybeUrl(input, {
|
|
4058
|
+
...parsedUrl,
|
|
4059
|
+
host: maybeTargetIp,
|
|
4060
|
+
port
|
|
4061
|
+
});
|
|
4062
|
+
const headersOverride = headerFactory(options?.headers ?? {});
|
|
4063
|
+
if (!headersOverride.has("Host")) {
|
|
4064
|
+
headersOverride.set("Host", host);
|
|
4065
|
+
}
|
|
4066
|
+
const optionsOverride = {
|
|
4067
|
+
...options,
|
|
4068
|
+
headers: headersOverride
|
|
4069
|
+
};
|
|
4070
|
+
try {
|
|
4071
|
+
const res = await fetch2(target.toString(), optionsOverride);
|
|
4072
|
+
return res;
|
|
4073
|
+
} catch (e) {
|
|
4074
|
+
if (e && e?.code === "ETIMEDOUT") {
|
|
4075
|
+
dnsCache.removeCache(hostname);
|
|
4026
4076
|
}
|
|
4027
|
-
|
|
4028
|
-
} else {
|
|
4029
|
-
return new ConductorClient(config, requestHandler);
|
|
4077
|
+
throw e;
|
|
4030
4078
|
}
|
|
4031
4079
|
};
|
|
4080
|
+
return fetchWithDns;
|
|
4032
4081
|
};
|
|
4033
|
-
|
|
4034
|
-
// src/orkes/OrkesConductorClient.ts
|
|
4035
|
-
var import_node_fetch = __toESM(require("node-fetch"));
|
|
4036
|
-
var import_http = __toESM(require("http"));
|
|
4037
|
-
var import_https = __toESM(require("https"));
|
|
4038
|
-
var httpAgent = new import_http.default.Agent({ keepAlive: true });
|
|
4039
|
-
var httpsAgent = new import_https.default.Agent({ keepAlive: true });
|
|
4040
|
-
var agent = (_parsedURL) => _parsedURL.protocol == "http:" ? httpAgent : httpsAgent;
|
|
4041
|
-
var nodeFetchWrapper = async (input, options = {}) => {
|
|
4042
|
-
const res = await (0, import_node_fetch.default)(input.toString(), {
|
|
4043
|
-
...options,
|
|
4044
|
-
agent
|
|
4045
|
-
});
|
|
4046
|
-
return res;
|
|
4047
|
-
};
|
|
4048
|
-
var fetchCache = fetchCatchDns(
|
|
4049
|
-
nodeFetchWrapper,
|
|
4050
|
-
{
|
|
4051
|
-
//@ts-ignore
|
|
4052
|
-
headerFactory: (headers) => new import_node_fetch.Headers(headers || {})
|
|
4053
|
-
}
|
|
4054
|
-
);
|
|
4055
|
-
var defaultRequestHandler3 = (__request, config, options) => request2(config, options, fetchCache);
|
|
4056
|
-
var orkesConductorClient = baseOrkesConductorClient(
|
|
4057
|
-
fetchCache,
|
|
4058
|
-
defaultRequestHandler3
|
|
4059
|
-
);
|
|
4060
4082
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4061
4083
|
0 && (module.exports = {
|
|
4062
4084
|
ApiError,
|