@camunda8/orchestration-cluster-api 8.9.0-alpha.12 → 8.9.0-alpha.13

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/fp/index.cjs CHANGED
@@ -12311,7 +12311,7 @@ function createLogger(opts = {}) {
12311
12311
  }
12312
12312
 
12313
12313
  // src/runtime/version.ts
12314
- var packageVersion = "8.9.0-alpha.12";
12314
+ var packageVersion = "8.9.0-alpha.13";
12315
12315
 
12316
12316
  // src/runtime/supportLogger.ts
12317
12317
  var NoopSupportLogger = class {
@@ -13111,6 +13111,7 @@ async function executeWithHttpRetry(fn, policy, logger, classify = defaultHttpCl
13111
13111
  var BackpressureManager = class {
13112
13112
  logger;
13113
13113
  now;
13114
+ sleep;
13114
13115
  cfg;
13115
13116
  severity = "healthy";
13116
13117
  consecutive = 0;
@@ -13123,9 +13124,12 @@ var BackpressureManager = class {
13123
13124
  observeOnly = false;
13124
13125
  healthySince = 0;
13125
13126
  // timestamp when severity last became healthy
13127
+ backoffMs = 0;
13128
+ // current backoff delay in ms (0 = no backoff)
13126
13129
  constructor(opts = {}) {
13127
13130
  this.logger = opts.logger;
13128
13131
  this.now = opts.now || (() => Date.now());
13132
+ this.sleep = opts.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
13129
13133
  this.cfg = {
13130
13134
  enabled: true,
13131
13135
  initialMaxConcurrency: null,
@@ -13139,6 +13143,9 @@ var BackpressureManager = class {
13139
13143
  maxWaiters: 1e3,
13140
13144
  healthyRecoveryMultiplier: 1.5,
13141
13145
  unlimitedAfterHealthyMs: 3e4,
13146
+ backoffInitialMs: 25,
13147
+ backoffMaxMs: 2e3,
13148
+ backoffEscalate: 2,
13142
13149
  ...opts.config
13143
13150
  };
13144
13151
  this.observeOnly = !!this.cfg.observeOnly;
@@ -13154,7 +13161,8 @@ var BackpressureManager = class {
13154
13161
  // When disabled, report unlimited semantics explicitly
13155
13162
  permitsMax: this.cfg.enabled === false ? null : this.permitsMax,
13156
13163
  permitsCurrent: this.cfg.enabled === false ? 0 : this.permitsCurrent,
13157
- waiters: this.waiters.length
13164
+ waiters: this.waiters.length,
13165
+ backoffMs: this.backoffMs
13158
13166
  };
13159
13167
  }
13160
13168
  log(evt, data, prevSeverity) {
@@ -13176,6 +13184,10 @@ var BackpressureManager = class {
13176
13184
  if (this.observeOnly) return;
13177
13185
  if (!this.isEnabled()) return;
13178
13186
  if (this.permitsMax === null) return;
13187
+ if (this.backoffMs > 0) {
13188
+ await this.sleep(this.backoffMs);
13189
+ if (this.permitsMax === null) return;
13190
+ }
13179
13191
  if (this.permitsCurrent < (this.permitsMax || 0)) {
13180
13192
  this.permitsCurrent++;
13181
13193
  return;
@@ -13239,11 +13251,23 @@ var BackpressureManager = class {
13239
13251
  } else if (this.severity === "soft") {
13240
13252
  if (!this.observeOnly) this.scalePermits(this.cfg.reduceFactor);
13241
13253
  }
13254
+ if (!this.observeOnly && this.permitsMax !== null && this.permitsMax <= this.cfg.floorConcurrency && this.severity === "severe") {
13255
+ if (this.backoffMs === 0) {
13256
+ this.backoffMs = this.cfg.backoffInitialMs;
13257
+ } else {
13258
+ this.backoffMs = Math.min(this.cfg.backoffMaxMs, this.backoffMs * this.cfg.backoffEscalate);
13259
+ }
13260
+ this.log("backoff.escalate", { delayMs: this.backoffMs });
13261
+ }
13242
13262
  if (this.severity !== prevSeverity)
13243
13263
  this.log("severity", { severity: this.severity }, prevSeverity);
13244
13264
  }
13245
13265
  recordHealthyHint() {
13246
13266
  if (!this.cfg.enabled && !this.observeOnly) return;
13267
+ if (this.backoffMs > 0) {
13268
+ this.backoffMs = 0;
13269
+ this.log("backoff.clear", { reason: "healthy-hint" });
13270
+ }
13247
13271
  const now2 = this.now();
13248
13272
  this.maybeRecover(now2);
13249
13273
  }
@@ -13267,13 +13291,23 @@ var BackpressureManager = class {
13267
13291
  this.healthySince = now2;
13268
13292
  }
13269
13293
  if (this.severity === "healthy") this.consecutive = 0;
13270
- if (prev !== this.severity) this.log("severity", { severity: this.severity }, prev);
13294
+ if (prev !== this.severity) {
13295
+ if (this.backoffMs > 0) {
13296
+ this.backoffMs = 0;
13297
+ this.log("backoff.clear", { reason: "severity-decay" });
13298
+ }
13299
+ this.log("severity", { severity: this.severity }, prev);
13300
+ }
13271
13301
  }
13272
13302
  if (this.permitsMax !== null) {
13273
13303
  const bootstrapCap = this.cfg.initialMaxConcurrency ?? 16;
13274
13304
  if (this.severity !== "healthy") {
13275
13305
  if (this.permitsMax < bootstrapCap) {
13276
13306
  this.permitsMax = Math.min(bootstrapCap, this.permitsMax + this.cfg.recoveryStep);
13307
+ if (this.permitsMax > this.cfg.floorConcurrency && this.backoffMs > 0) {
13308
+ this.backoffMs = 0;
13309
+ this.log("backoff.clear", { reason: "left-floor" });
13310
+ }
13277
13311
  this.log("permits.recover", { max: this.permitsMax, phase: "additive" }, this.severity);
13278
13312
  this.release();
13279
13313
  }
@@ -13281,6 +13315,7 @@ var BackpressureManager = class {
13281
13315
  if (this.healthySince > 0 && now2 - this.healthySince >= this.cfg.unlimitedAfterHealthyMs) {
13282
13316
  this.permitsMax = null;
13283
13317
  this.permitsCurrent = 0;
13318
+ this.backoffMs = 0;
13284
13319
  while (this.waiters.length) {
13285
13320
  const w = this.waiters.shift();
13286
13321
  try {