@camunda8/orchestration-cluster-api 10.0.0-alpha.37 → 10.0.0-alpha.39
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/CHANGELOG.md +14 -0
- package/README.md +125 -5
- package/dist/{CamundaClient-BdKNRD2i.d.ts → CamundaClient-Crt5W0EI.d.ts} +73 -9
- package/dist/{CamundaClient-DKCeKUmK.d.cts → CamundaClient-VlYVveFG.d.cts} +73 -9
- package/dist/{chunk-QMVXOINT.js → chunk-LNMC2FKC.js} +143 -74
- package/dist/chunk-LNMC2FKC.js.map +1 -0
- package/dist/effect/index.cjs +177 -74
- package/dist/effect/index.cjs.map +1 -1
- package/dist/effect/index.d.cts +48 -4
- package/dist/effect/index.d.ts +48 -4
- package/dist/effect/index.js +45 -8
- package/dist/effect/index.js.map +1 -1
- package/dist/index.cjs +144 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/chunk-QMVXOINT.js.map +0 -1
package/dist/effect/index.cjs
CHANGED
|
@@ -14156,7 +14156,7 @@ function createLogger(opts = {}) {
|
|
|
14156
14156
|
}
|
|
14157
14157
|
|
|
14158
14158
|
// src/runtime/version.ts
|
|
14159
|
-
var packageVersion = "10.0.0-alpha.
|
|
14159
|
+
var packageVersion = "10.0.0-alpha.39";
|
|
14160
14160
|
|
|
14161
14161
|
// src/runtime/supportLogger.ts
|
|
14162
14162
|
var NoopSupportLogger = class {
|
|
@@ -15188,6 +15188,66 @@ var BackpressureManager = class {
|
|
|
15188
15188
|
}
|
|
15189
15189
|
};
|
|
15190
15190
|
|
|
15191
|
+
// src/runtime/clock.ts
|
|
15192
|
+
var SLEW_DIVISOR = 16;
|
|
15193
|
+
var MAX_TIMER_MS = 2147483647;
|
|
15194
|
+
function scheduleLong(ms, onElapsed) {
|
|
15195
|
+
let remaining = Math.max(0, ms);
|
|
15196
|
+
let timer;
|
|
15197
|
+
const step = () => {
|
|
15198
|
+
const slice = Math.min(remaining, MAX_TIMER_MS);
|
|
15199
|
+
remaining -= slice;
|
|
15200
|
+
timer = setTimeout(remaining > 0 ? step : onElapsed, slice);
|
|
15201
|
+
};
|
|
15202
|
+
step();
|
|
15203
|
+
return () => clearTimeout(timer);
|
|
15204
|
+
}
|
|
15205
|
+
function createLiveClock(source = Date.now) {
|
|
15206
|
+
let lastSource = source();
|
|
15207
|
+
let offsetMs = 0;
|
|
15208
|
+
let slewCreditMs = 0;
|
|
15209
|
+
const now2 = () => {
|
|
15210
|
+
const observed = source();
|
|
15211
|
+
if (observed < lastSource) {
|
|
15212
|
+
offsetMs += lastSource - observed;
|
|
15213
|
+
} else if (offsetMs > 0) {
|
|
15214
|
+
slewCreditMs += observed - lastSource;
|
|
15215
|
+
const repay = Math.floor(slewCreditMs / SLEW_DIVISOR);
|
|
15216
|
+
if (repay > 0) {
|
|
15217
|
+
slewCreditMs -= repay * SLEW_DIVISOR;
|
|
15218
|
+
offsetMs -= Math.min(offsetMs, repay);
|
|
15219
|
+
}
|
|
15220
|
+
}
|
|
15221
|
+
lastSource = observed;
|
|
15222
|
+
return observed + offsetMs;
|
|
15223
|
+
};
|
|
15224
|
+
const sleep2 = (ms, signal) => new Promise((resolve, reject) => {
|
|
15225
|
+
if (signal?.aborted) {
|
|
15226
|
+
reject(signal.reason);
|
|
15227
|
+
return;
|
|
15228
|
+
}
|
|
15229
|
+
const cancel = scheduleLong(ms, () => {
|
|
15230
|
+
signal?.removeEventListener("abort", onAbort);
|
|
15231
|
+
resolve();
|
|
15232
|
+
});
|
|
15233
|
+
function onAbort() {
|
|
15234
|
+
cancel();
|
|
15235
|
+
reject(signal?.reason);
|
|
15236
|
+
}
|
|
15237
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
15238
|
+
});
|
|
15239
|
+
const deadline = (ms) => {
|
|
15240
|
+
const controller = new AbortController();
|
|
15241
|
+
const cancel = scheduleLong(
|
|
15242
|
+
ms,
|
|
15243
|
+
() => controller.abort(new DOMException(`Timed out after ${ms}ms`, "TimeoutError"))
|
|
15244
|
+
);
|
|
15245
|
+
return { signal: controller.signal, dispose: cancel };
|
|
15246
|
+
};
|
|
15247
|
+
return { now: now2, sleep: sleep2, deadline };
|
|
15248
|
+
}
|
|
15249
|
+
var liveClock = createLiveClock();
|
|
15250
|
+
|
|
15191
15251
|
// src/runtime/typedVariables.ts
|
|
15192
15252
|
var TypedVariablesError = class extends Error {
|
|
15193
15253
|
constructor(message, options) {
|
|
@@ -15421,6 +15481,51 @@ function nextActivationRetryDelayMs(attempt, cfg, rng) {
|
|
|
15421
15481
|
return Number.isFinite(cfg.pollIntervalMs) ? Math.max(0, Math.round(cfg.pollIntervalMs)) : 0;
|
|
15422
15482
|
}
|
|
15423
15483
|
|
|
15484
|
+
// src/runtime/workerGracefulStop.ts
|
|
15485
|
+
async function stopWorkerGracefully(deps, opts) {
|
|
15486
|
+
const waitUpToMs = opts?.waitUpToMs ?? 5e3;
|
|
15487
|
+
const checkIntervalMs = opts?.checkIntervalMs ?? 10;
|
|
15488
|
+
deps.haltPolling();
|
|
15489
|
+
const start = liveClock.now();
|
|
15490
|
+
const inFlight = deps.inFlightActivation();
|
|
15491
|
+
if (inFlight) {
|
|
15492
|
+
const budget = liveClock.deadline(waitUpToMs);
|
|
15493
|
+
try {
|
|
15494
|
+
await Promise.race([
|
|
15495
|
+
inFlight,
|
|
15496
|
+
new Promise((_, rej) => {
|
|
15497
|
+
const reject = () => rej(new Error("activation.wait.timeout"));
|
|
15498
|
+
if (budget.signal.aborted) reject();
|
|
15499
|
+
else budget.signal.addEventListener("abort", reject, { once: true });
|
|
15500
|
+
})
|
|
15501
|
+
]);
|
|
15502
|
+
} catch (e) {
|
|
15503
|
+
if (e && e.message === "activation.wait.timeout") {
|
|
15504
|
+
deps.log.debug("worker.gracefulStop.activationTimeout");
|
|
15505
|
+
}
|
|
15506
|
+
} finally {
|
|
15507
|
+
budget.dispose();
|
|
15508
|
+
}
|
|
15509
|
+
}
|
|
15510
|
+
while (deps.activeJobs() > 0 && liveClock.now() - start < waitUpToMs) {
|
|
15511
|
+
await liveClock.sleep(checkIntervalMs);
|
|
15512
|
+
}
|
|
15513
|
+
const timedOut = deps.activeJobs() > 0;
|
|
15514
|
+
if (timedOut) {
|
|
15515
|
+
const pending = deps.inFlightActivation();
|
|
15516
|
+
if (pending?.cancel) {
|
|
15517
|
+
try {
|
|
15518
|
+
pending.cancel();
|
|
15519
|
+
} catch {
|
|
15520
|
+
}
|
|
15521
|
+
}
|
|
15522
|
+
deps.log.debug("worker.gracefulStop.timeout", { remaining: deps.activeJobs() });
|
|
15523
|
+
} else {
|
|
15524
|
+
deps.log.debug("worker.gracefulStop.done");
|
|
15525
|
+
}
|
|
15526
|
+
return { remainingJobs: deps.activeJobs(), timedOut };
|
|
15527
|
+
}
|
|
15528
|
+
|
|
15424
15529
|
// src/runtime/workerStartGate.ts
|
|
15425
15530
|
var WorkerStartGate = class {
|
|
15426
15531
|
/**
|
|
@@ -15567,42 +15672,19 @@ var JobWorker = class {
|
|
|
15567
15672
|
* If timeout is reached, falls back to hard stop logic (cancels activation if still pending).
|
|
15568
15673
|
*/
|
|
15569
15674
|
async stopGracefully(opts) {
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
|
|
15575
|
-
|
|
15576
|
-
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
]);
|
|
15584
|
-
} catch (e) {
|
|
15585
|
-
if (e && e.message === "activation.wait.timeout") {
|
|
15586
|
-
this._log.debug("worker.gracefulStop.activationTimeout");
|
|
15587
|
-
}
|
|
15588
|
-
}
|
|
15589
|
-
}
|
|
15590
|
-
while (this._activeJobs > 0 && Date.now() - start < waitUpToMs) {
|
|
15591
|
-
await new Promise((r) => setTimeout(r, checkIntervalMs));
|
|
15592
|
-
}
|
|
15593
|
-
const timedOut = this._activeJobs > 0;
|
|
15594
|
-
if (timedOut) {
|
|
15595
|
-
if (this._inFlightActivation?.cancel) {
|
|
15596
|
-
try {
|
|
15597
|
-
this._inFlightActivation.cancel();
|
|
15598
|
-
} catch {
|
|
15599
|
-
}
|
|
15600
|
-
}
|
|
15601
|
-
this._log.debug("worker.gracefulStop.timeout", { remaining: this._activeJobs });
|
|
15602
|
-
} else {
|
|
15603
|
-
this._log.debug("worker.gracefulStop.done");
|
|
15604
|
-
}
|
|
15605
|
-
return { remainingJobs: this._activeJobs, timedOut };
|
|
15675
|
+
return stopWorkerGracefully(
|
|
15676
|
+
{
|
|
15677
|
+
haltPolling: () => {
|
|
15678
|
+
this._stopped = true;
|
|
15679
|
+
if (this._pollTimer) clearTimeout(this._pollTimer);
|
|
15680
|
+
this._pollTimer = null;
|
|
15681
|
+
},
|
|
15682
|
+
activeJobs: () => this._activeJobs,
|
|
15683
|
+
inFlightActivation: () => this._inFlightActivation,
|
|
15684
|
+
log: this._log
|
|
15685
|
+
},
|
|
15686
|
+
opts
|
|
15687
|
+
);
|
|
15606
15688
|
}
|
|
15607
15689
|
_scheduleNext(delayMs) {
|
|
15608
15690
|
if (this._stopped) return;
|
|
@@ -15895,42 +15977,19 @@ var ThreadedJobWorker = class {
|
|
|
15895
15977
|
this._log.info("worker.stop");
|
|
15896
15978
|
}
|
|
15897
15979
|
async stopGracefully(opts) {
|
|
15898
|
-
|
|
15899
|
-
|
|
15900
|
-
|
|
15901
|
-
|
|
15902
|
-
|
|
15903
|
-
|
|
15904
|
-
|
|
15905
|
-
|
|
15906
|
-
|
|
15907
|
-
|
|
15908
|
-
|
|
15909
|
-
|
|
15910
|
-
|
|
15911
|
-
]);
|
|
15912
|
-
} catch (e) {
|
|
15913
|
-
if (e && e.message === "activation.wait.timeout") {
|
|
15914
|
-
this._log.debug("worker.gracefulStop.activationTimeout");
|
|
15915
|
-
}
|
|
15916
|
-
}
|
|
15917
|
-
}
|
|
15918
|
-
while (this._activeJobs > 0 && Date.now() - start < waitUpToMs) {
|
|
15919
|
-
await new Promise((r) => setTimeout(r, checkIntervalMs));
|
|
15920
|
-
}
|
|
15921
|
-
const timedOut = this._activeJobs > 0;
|
|
15922
|
-
if (timedOut) {
|
|
15923
|
-
if (this._inFlightActivation?.cancel) {
|
|
15924
|
-
try {
|
|
15925
|
-
this._inFlightActivation.cancel();
|
|
15926
|
-
} catch {
|
|
15927
|
-
}
|
|
15928
|
-
}
|
|
15929
|
-
this._log.debug("worker.gracefulStop.timeout", { remaining: this._activeJobs });
|
|
15930
|
-
} else {
|
|
15931
|
-
this._log.debug("worker.gracefulStop.done");
|
|
15932
|
-
}
|
|
15933
|
-
return { remainingJobs: this._activeJobs, timedOut };
|
|
15980
|
+
return stopWorkerGracefully(
|
|
15981
|
+
{
|
|
15982
|
+
haltPolling: () => {
|
|
15983
|
+
this._stopped = true;
|
|
15984
|
+
if (this._pollTimer) clearTimeout(this._pollTimer);
|
|
15985
|
+
this._pollTimer = null;
|
|
15986
|
+
},
|
|
15987
|
+
activeJobs: () => this._activeJobs,
|
|
15988
|
+
inFlightActivation: () => this._inFlightActivation,
|
|
15989
|
+
log: this._log
|
|
15990
|
+
},
|
|
15991
|
+
opts
|
|
15992
|
+
);
|
|
15934
15993
|
}
|
|
15935
15994
|
// ─── Job dispatch ───
|
|
15936
15995
|
_drainQueue() {
|
|
@@ -16607,6 +16666,7 @@ var CamundaClientBase = class {
|
|
|
16607
16666
|
_validation = new ValidationManager({ req: "none", res: "none" });
|
|
16608
16667
|
_log = createLogger();
|
|
16609
16668
|
_bp;
|
|
16669
|
+
_clock = liveClock;
|
|
16610
16670
|
/** Registered job workers created via createJobWorker (lifecycle managed by user). */
|
|
16611
16671
|
_workers = [];
|
|
16612
16672
|
/** Shared thread pool for all threaded job workers (lazy-initialised on first use). */
|
|
@@ -16621,6 +16681,7 @@ var CamundaClientBase = class {
|
|
|
16621
16681
|
_overrides = {};
|
|
16622
16682
|
constructor(opts = {}) {
|
|
16623
16683
|
if (opts.config) this._overrides = { ...opts.config };
|
|
16684
|
+
this._clock = opts.clock ?? liveClock;
|
|
16624
16685
|
const { config } = hydrateConfig({ overrides: this._overrides, env: opts.env });
|
|
16625
16686
|
this._config = deepFreeze2(config);
|
|
16626
16687
|
this._log = createLogger({
|
|
@@ -16693,6 +16754,8 @@ var CamundaClientBase = class {
|
|
|
16693
16754
|
this.emitSupportLogPreamble();
|
|
16694
16755
|
this._bp = new BackpressureManager({
|
|
16695
16756
|
logger: this._log.scope("bp"),
|
|
16757
|
+
now: () => this._clock.now(),
|
|
16758
|
+
sleep: (ms) => this._clock.sleep(ms),
|
|
16696
16759
|
config: {
|
|
16697
16760
|
enabled: this._config.backpressure.enabled,
|
|
16698
16761
|
observeOnly: this._config.backpressure.observeOnly,
|
|
@@ -16895,6 +16958,10 @@ var CamundaClientBase = class {
|
|
|
16895
16958
|
_evaluateResponse(raw, opId, buildBackpressureError) {
|
|
16896
16959
|
return evaluateSdkResponse(raw, { opId, buildBackpressureError });
|
|
16897
16960
|
}
|
|
16961
|
+
/** Clock backing SDK-internal cadence. The injected one when supplied, else the live clock. */
|
|
16962
|
+
get clock() {
|
|
16963
|
+
return this._clock;
|
|
16964
|
+
}
|
|
16898
16965
|
/** Public accessor for current backpressure adaptive limiter state (stable) */
|
|
16899
16966
|
getBackpressureState() {
|
|
16900
16967
|
try {
|
|
@@ -30999,6 +31066,36 @@ function toDomainError(err) {
|
|
|
30999
31066
|
}
|
|
31000
31067
|
return new CamundaGenericError({ message: String(err), cause: err });
|
|
31001
31068
|
}
|
|
31069
|
+
function effectifyPaginate(search) {
|
|
31070
|
+
return (body, opts = {}) => {
|
|
31071
|
+
const { consistency, maxPages = Number.POSITIVE_INFINITY, mode = "auto" } = opts;
|
|
31072
|
+
const pagesFrom = (pageBody, remaining, isFirstPage) => {
|
|
31073
|
+
if (remaining <= 0) return import_effect.Stream.empty;
|
|
31074
|
+
const consistencyArg = {
|
|
31075
|
+
consistency: isFirstPage ? consistency ?? { waitUpToMs: 0 } : { waitUpToMs: 0 }
|
|
31076
|
+
};
|
|
31077
|
+
return import_effect.Stream.unwrap(
|
|
31078
|
+
search(pageBody, consistencyArg).pipe(
|
|
31079
|
+
import_effect.Effect.map((response) => {
|
|
31080
|
+
const next = nextPageRequest(pageBody, response, mode);
|
|
31081
|
+
const head = import_effect.Stream.make(response);
|
|
31082
|
+
return next === null ? head : import_effect.Stream.concat(head, pagesFrom(next, remaining - 1, false));
|
|
31083
|
+
})
|
|
31084
|
+
)
|
|
31085
|
+
);
|
|
31086
|
+
};
|
|
31087
|
+
const pages = () => pagesFrom(body, maxPages, true);
|
|
31088
|
+
const items = () => pages().pipe(
|
|
31089
|
+
import_effect.Stream.map((response) => response.items),
|
|
31090
|
+
import_effect.Stream.flattenIterable
|
|
31091
|
+
);
|
|
31092
|
+
return {
|
|
31093
|
+
pages,
|
|
31094
|
+
items,
|
|
31095
|
+
toArray: () => import_effect.Stream.runCollect(items()).pipe(import_effect.Effect.map((chunk) => [...chunk]))
|
|
31096
|
+
};
|
|
31097
|
+
};
|
|
31098
|
+
}
|
|
31002
31099
|
function isPromiseLike(v) {
|
|
31003
31100
|
return !!v && typeof v.then === "function";
|
|
31004
31101
|
}
|
|
@@ -31006,7 +31103,7 @@ function createCamundaEffectClient(options) {
|
|
|
31006
31103
|
const base = createCamundaClient(options);
|
|
31007
31104
|
const cache = /* @__PURE__ */ new Map();
|
|
31008
31105
|
function wrap(fn) {
|
|
31009
|
-
|
|
31106
|
+
const wrapped = (...args) => import_effect.Effect.suspend(() => {
|
|
31010
31107
|
let r;
|
|
31011
31108
|
try {
|
|
31012
31109
|
r = fn.apply(base, args);
|
|
@@ -31024,6 +31121,12 @@ function createCamundaEffectClient(options) {
|
|
|
31024
31121
|
return typeof cancel === "function" ? import_effect.Effect.sync(() => cancel.call(r)) : void 0;
|
|
31025
31122
|
});
|
|
31026
31123
|
});
|
|
31124
|
+
if (typeof fn.paginate === "function") {
|
|
31125
|
+
wrapped.paginate = effectifyPaginate(
|
|
31126
|
+
wrapped
|
|
31127
|
+
);
|
|
31128
|
+
}
|
|
31129
|
+
return wrapped;
|
|
31027
31130
|
}
|
|
31028
31131
|
const handler = {
|
|
31029
31132
|
get(_t, prop) {
|