@camunda8/orchestration-cluster-api 10.0.0-alpha.41 → 10.0.0-alpha.42

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,6 +1,6 @@
1
1
  import {
2
2
  createLogger
3
- } from "./chunk-KQ4UL2WX.js";
3
+ } from "./chunk-LXWPMQOS.js";
4
4
  import {
5
5
  __require
6
6
  } from "./chunk-DGUM43GV.js";
@@ -64,6 +64,82 @@ function createLiveClock(source = () => Date.now()) {
64
64
  return { now, sleep, deadline };
65
65
  }
66
66
  var liveClock = createLiveClock();
67
+ function createTestClock(options = {}) {
68
+ const { start = 0, autoAdvance = true } = options;
69
+ let current = start;
70
+ let nowCalls = 0;
71
+ const sleeps = [];
72
+ let waiters = [];
73
+ const settleDue = () => {
74
+ const due = waiters.filter((w) => w.at <= current);
75
+ waiters = waiters.filter((w) => w.at > current);
76
+ for (const w of due) {
77
+ w.detach();
78
+ w.resolve();
79
+ }
80
+ };
81
+ const nextTick = (fn) => {
82
+ setTimeout(fn, 0);
83
+ };
84
+ const now = () => {
85
+ nowCalls += 1;
86
+ return current;
87
+ };
88
+ const requireDuration = (ms, label) => {
89
+ if (!Number.isFinite(ms) || ms < 0) {
90
+ throw new RangeError(`${label} needs a finite, non-negative duration in ms, got ${ms}`);
91
+ }
92
+ };
93
+ const sleep = (ms, signal) => new Promise((resolve, reject) => {
94
+ requireDuration(ms, "clock.sleep");
95
+ if (signal?.aborted) {
96
+ reject(signal.reason);
97
+ return;
98
+ }
99
+ sleeps.push(ms);
100
+ const waiter = { at: current + ms, resolve, detach: () => {
101
+ } };
102
+ if (signal) {
103
+ const onAbort = () => {
104
+ waiters = waiters.filter((w) => w !== waiter);
105
+ reject(signal.reason);
106
+ };
107
+ signal.addEventListener("abort", onAbort, { once: true });
108
+ waiter.detach = () => signal.removeEventListener("abort", onAbort);
109
+ }
110
+ waiters.push(waiter);
111
+ if (autoAdvance) {
112
+ nextTick(() => {
113
+ if (!waiters.includes(waiter)) return;
114
+ current = Math.max(current, waiter.at);
115
+ settleDue();
116
+ });
117
+ }
118
+ });
119
+ const advance = async (ms) => {
120
+ requireDuration(ms, "clock.advance");
121
+ current += ms;
122
+ settleDue();
123
+ await new Promise((resolve) => nextTick(resolve));
124
+ };
125
+ return {
126
+ now,
127
+ sleep,
128
+ advance,
129
+ // A deadline bounds liveness rather than pacing cadence: it stays on real time even
130
+ // here, because code guarded by one should time out rather than hang on a pinned clock.
131
+ deadline: (ms) => liveClock.deadline(ms),
132
+ get sleeps() {
133
+ return sleeps;
134
+ },
135
+ get nowCalls() {
136
+ return nowCalls;
137
+ },
138
+ get pending() {
139
+ return waiters.length;
140
+ }
141
+ };
142
+ }
67
143
 
68
144
  // src/runtime/errors.ts
69
145
  function isSdkError(e) {
@@ -4081,6 +4157,7 @@ var OAuthManager = class {
4081
4157
  if (attempt === 0) {
4082
4158
  const evt = {
4083
4159
  type: "auth.start",
4160
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4084
4161
  ts: Date.now(),
4085
4162
  audience: this.cfg.tokenAudience,
4086
4163
  endpoint: this.cfg.oauth.oauthUrl,
@@ -4132,6 +4209,7 @@ var OAuthManager = class {
4132
4209
  try {
4133
4210
  const evt = {
4134
4211
  type: "auth.success",
4212
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4135
4213
  ts: Date.now(),
4136
4214
  audience: this.cfg.tokenAudience,
4137
4215
  endpoint: this.cfg.oauth.oauthUrl,
@@ -4156,6 +4234,7 @@ var OAuthManager = class {
4156
4234
  try {
4157
4235
  this.tHooks?.retry?.({
4158
4236
  type: "retry",
4237
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4159
4238
  ts: Date.now(),
4160
4239
  attempt,
4161
4240
  nextDelayMs: Math.round(sleep),
@@ -4171,6 +4250,7 @@ var OAuthManager = class {
4171
4250
  try {
4172
4251
  const evt = {
4173
4252
  type: "auth.error",
4253
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4174
4254
  ts: Date.now(),
4175
4255
  audience: this.cfg.tokenAudience,
4176
4256
  endpoint: this.cfg.oauth.oauthUrl,
@@ -5285,7 +5365,7 @@ function installAuthInterceptor(client2, getStrategy, getAuthHeaders) {
5285
5365
  }
5286
5366
 
5287
5367
  // src/runtime/version.ts
5288
- var packageVersion = "10.0.0-alpha.41";
5368
+ var packageVersion = "10.0.0-alpha.42";
5289
5369
 
5290
5370
  // src/runtime/supportLogger.ts
5291
5371
  var NoopSupportLogger = class {
@@ -5933,6 +6013,7 @@ function detectExtrasAndMaybeThrow(opts) {
5933
6013
  const payload = {
5934
6014
  operationId,
5935
6015
  extras,
6016
+ // biome-ignore lint/plugin: capture-artifact timestamp: records when the capture was written, not cadence
5936
6017
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5937
6018
  sample: value
5938
6019
  };
@@ -6104,8 +6185,8 @@ var BackpressureManager = class {
6104
6185
  // current backoff delay in ms (0 = no backoff)
6105
6186
  constructor(opts = {}) {
6106
6187
  this.logger = opts.logger;
6107
- this.now = opts.now || (() => Date.now());
6108
- this.sleep = opts.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
6188
+ this.now = opts.now || (() => liveClock.now());
6189
+ this.sleep = opts.sleep || ((ms) => liveClock.sleep(ms));
6109
6190
  this.cfg = {
6110
6191
  enabled: true,
6111
6192
  initialMaxConcurrency: null,
@@ -21471,6 +21552,7 @@ var CamundaClient = CamundaClientBase;
21471
21552
  export {
21472
21553
  createLiveClock,
21473
21554
  liveClock,
21555
+ createTestClock,
21474
21556
  isSdkError,
21475
21557
  CamundaValidationError,
21476
21558
  EventualConsistencyTimeoutError,
@@ -21488,4 +21570,4 @@ export {
21488
21570
  createCamundaClient,
21489
21571
  CamundaClient
21490
21572
  };
21491
- //# sourceMappingURL=chunk-267HUCFY.js.map
21573
+ //# sourceMappingURL=chunk-4F4DVIJW.js.map