@camunda8/orchestration-cluster-api 10.0.0-alpha.37 → 10.0.0-alpha.38

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.
@@ -1,7 +1,7 @@
1
1
  import * as effect_Cause from 'effect/Cause';
2
2
  import * as effect_Types from 'effect/Types';
3
3
  import { Context, Effect, Duration, Layer, Schedule, Cause, Stream, Scope } from 'effect';
4
- import { C as CamundaClient, a as CamundaOptions, A as ActivatedJobResult } from '../CamundaClient-DKCeKUmK.cjs';
4
+ import { C as CamundaClient, a as CamundaOptions, A as ActivatedJobResult } from '../CamundaClient-CvdIL8uM.cjs';
5
5
  import 'zod';
6
6
  import '../logger-D-p21VHo.cjs';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import * as effect_Cause from 'effect/Cause';
2
2
  import * as effect_Types from 'effect/Types';
3
3
  import { Context, Effect, Duration, Layer, Schedule, Cause, Stream, Scope } from 'effect';
4
- import { C as CamundaClient, a as CamundaOptions, A as ActivatedJobResult } from '../CamundaClient-BdKNRD2i.js';
4
+ import { C as CamundaClient, a as CamundaOptions, A as ActivatedJobResult } from '../CamundaClient-BMOpGKIo.js';
5
5
  import 'zod';
6
6
  import '../logger-D-p21VHo.js';
7
7
 
@@ -2,7 +2,7 @@ import {
2
2
  CamundaValidationError,
3
3
  EventualConsistencyTimeoutError,
4
4
  createCamundaClient
5
- } from "../chunk-QMVXOINT.js";
5
+ } from "../chunk-LPNUMNEM.js";
6
6
  import "../chunk-KQ4UL2WX.js";
7
7
  import "../chunk-DGUM43GV.js";
8
8
 
package/dist/index.cjs CHANGED
@@ -9612,10 +9612,12 @@ __export(index_exports, {
9612
9612
  createCamundaClient: () => createCamundaClient,
9613
9613
  createCamundaClientLoose: () => createCamundaClientLoose,
9614
9614
  createCamundaResultClient: () => createCamundaResultClient,
9615
+ createLiveClock: () => createLiveClock,
9615
9616
  default: () => index_default,
9616
9617
  isErr: () => isErr,
9617
9618
  isOk: () => isOk,
9618
9619
  isSdkError: () => isSdkError,
9620
+ liveClock: () => liveClock,
9619
9621
  nextPageRequest: () => nextPageRequest,
9620
9622
  paginate: () => paginate,
9621
9623
  variableNamesFromSchema: () => variableNamesFromSchema
@@ -14239,7 +14241,7 @@ function createLogger(opts = {}) {
14239
14241
  }
14240
14242
 
14241
14243
  // src/runtime/version.ts
14242
- var packageVersion = "10.0.0-alpha.37";
14244
+ var packageVersion = "10.0.0-alpha.38";
14243
14245
 
14244
14246
  // src/runtime/supportLogger.ts
14245
14247
  var NoopSupportLogger = class {
@@ -15271,6 +15273,66 @@ var BackpressureManager = class {
15271
15273
  }
15272
15274
  };
15273
15275
 
15276
+ // src/runtime/clock.ts
15277
+ var SLEW_DIVISOR = 16;
15278
+ var MAX_TIMER_MS = 2147483647;
15279
+ function scheduleLong(ms, onElapsed) {
15280
+ let remaining = Math.max(0, ms);
15281
+ let timer;
15282
+ const step = () => {
15283
+ const slice = Math.min(remaining, MAX_TIMER_MS);
15284
+ remaining -= slice;
15285
+ timer = setTimeout(remaining > 0 ? step : onElapsed, slice);
15286
+ };
15287
+ step();
15288
+ return () => clearTimeout(timer);
15289
+ }
15290
+ function createLiveClock(source = Date.now) {
15291
+ let lastSource = source();
15292
+ let offsetMs = 0;
15293
+ let slewCreditMs = 0;
15294
+ const now2 = () => {
15295
+ const observed = source();
15296
+ if (observed < lastSource) {
15297
+ offsetMs += lastSource - observed;
15298
+ } else if (offsetMs > 0) {
15299
+ slewCreditMs += observed - lastSource;
15300
+ const repay = Math.floor(slewCreditMs / SLEW_DIVISOR);
15301
+ if (repay > 0) {
15302
+ slewCreditMs -= repay * SLEW_DIVISOR;
15303
+ offsetMs -= Math.min(offsetMs, repay);
15304
+ }
15305
+ }
15306
+ lastSource = observed;
15307
+ return observed + offsetMs;
15308
+ };
15309
+ const sleep2 = (ms, signal) => new Promise((resolve, reject) => {
15310
+ if (signal?.aborted) {
15311
+ reject(signal.reason);
15312
+ return;
15313
+ }
15314
+ const cancel = scheduleLong(ms, () => {
15315
+ signal?.removeEventListener("abort", onAbort);
15316
+ resolve();
15317
+ });
15318
+ function onAbort() {
15319
+ cancel();
15320
+ reject(signal?.reason);
15321
+ }
15322
+ signal?.addEventListener("abort", onAbort, { once: true });
15323
+ });
15324
+ const deadline = (ms) => {
15325
+ const controller = new AbortController();
15326
+ const cancel = scheduleLong(
15327
+ ms,
15328
+ () => controller.abort(new DOMException(`Timed out after ${ms}ms`, "TimeoutError"))
15329
+ );
15330
+ return { signal: controller.signal, dispose: cancel };
15331
+ };
15332
+ return { now: now2, sleep: sleep2, deadline };
15333
+ }
15334
+ var liveClock = createLiveClock();
15335
+
15274
15336
  // src/runtime/typedVariables.ts
15275
15337
  var TypedVariablesError = class extends Error {
15276
15338
  constructor(message, options) {
@@ -16696,6 +16758,7 @@ var CamundaClientBase = class {
16696
16758
  _validation = new ValidationManager({ req: "none", res: "none" });
16697
16759
  _log = createLogger();
16698
16760
  _bp;
16761
+ _clock = liveClock;
16699
16762
  /** Registered job workers created via createJobWorker (lifecycle managed by user). */
16700
16763
  _workers = [];
16701
16764
  /** Shared thread pool for all threaded job workers (lazy-initialised on first use). */
@@ -16710,6 +16773,7 @@ var CamundaClientBase = class {
16710
16773
  _overrides = {};
16711
16774
  constructor(opts = {}) {
16712
16775
  if (opts.config) this._overrides = { ...opts.config };
16776
+ this._clock = opts.clock ?? liveClock;
16713
16777
  const { config } = hydrateConfig({ overrides: this._overrides, env: opts.env });
16714
16778
  this._config = deepFreeze2(config);
16715
16779
  this._log = createLogger({
@@ -16782,6 +16846,8 @@ var CamundaClientBase = class {
16782
16846
  this.emitSupportLogPreamble();
16783
16847
  this._bp = new BackpressureManager({
16784
16848
  logger: this._log.scope("bp"),
16849
+ now: () => this._clock.now(),
16850
+ sleep: (ms) => this._clock.sleep(ms),
16785
16851
  config: {
16786
16852
  enabled: this._config.backpressure.enabled,
16787
16853
  observeOnly: this._config.backpressure.observeOnly,
@@ -16984,6 +17050,10 @@ var CamundaClientBase = class {
16984
17050
  _evaluateResponse(raw, opId, buildBackpressureError) {
16985
17051
  return evaluateSdkResponse(raw, { opId, buildBackpressureError });
16986
17052
  }
17053
+ /** Clock backing SDK-internal cadence. The injected one when supplied, else the live clock. */
17054
+ get clock() {
17055
+ return this._clock;
17056
+ }
16987
17057
  /** Public accessor for current backpressure adaptive limiter state (stable) */
16988
17058
  getBackpressureState() {
16989
17059
  try {
@@ -32407,9 +32477,11 @@ var index_default = createCamundaClient;
32407
32477
  createCamundaClient,
32408
32478
  createCamundaClientLoose,
32409
32479
  createCamundaResultClient,
32480
+ createLiveClock,
32410
32481
  isErr,
32411
32482
  isOk,
32412
32483
  isSdkError,
32484
+ liveClock,
32413
32485
  nextPageRequest,
32414
32486
  paginate,
32415
32487
  variableNamesFromSchema