@camunda8/orchestration-cluster-api 10.0.0-alpha.20 → 10.0.0-alpha.21

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,3 +1,3 @@
1
- export { dr as CamundaFpClient, Hx as DomainError, Hy as DomainErrorTag, iI as Either, Hz as FnKeys, HA as Fpify, HB as HttpError, HC as Left, HD as Right, HE as TaskEither, HF as classifyDomainError, D3 as createCamundaFpClient, HG as eventuallyTE, HH as foldDomainError, Fe as isLeft, Ff as isRight, HI as retryTE, HJ as withTimeoutTE } from '../index-B-TWQXn0.cjs';
1
+ export { dr as CamundaFpClient, Hx as DomainError, Hy as DomainErrorTag, iI as Either, Hz as FnKeys, HA as Fpify, HB as HttpError, HC as Left, HD as Right, HE as TaskEither, HF as classifyDomainError, D3 as createCamundaFpClient, HG as eventuallyTE, HH as foldDomainError, Fe as isLeft, Ff as isRight, HI as retryTE, HJ as withTimeoutTE } from '../index-DPNy4KLk.cjs';
2
2
  import 'zod';
3
3
  import '../logger-D-p21VHo.cjs';
@@ -1,3 +1,3 @@
1
- export { dr as CamundaFpClient, Hx as DomainError, Hy as DomainErrorTag, iI as Either, Hz as FnKeys, HA as Fpify, HB as HttpError, HC as Left, HD as Right, HE as TaskEither, HF as classifyDomainError, D3 as createCamundaFpClient, HG as eventuallyTE, HH as foldDomainError, Fe as isLeft, Ff as isRight, HI as retryTE, HJ as withTimeoutTE } from '../index-CLUX1eAN.js';
1
+ export { dr as CamundaFpClient, Hx as DomainError, Hy as DomainErrorTag, iI as Either, Hz as FnKeys, HA as Fpify, HB as HttpError, HC as Left, HD as Right, HE as TaskEither, HF as classifyDomainError, D3 as createCamundaFpClient, HG as eventuallyTE, HH as foldDomainError, Fe as isLeft, Ff as isRight, HI as retryTE, HJ as withTimeoutTE } from '../index-CE5WmteM.js';
2
2
  import 'zod';
3
3
  import '../logger-D-p21VHo.js';
package/dist/fp/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  isRight,
8
8
  retryTE,
9
9
  withTimeoutTE
10
- } from "../chunk-QZDJRG7I.js";
10
+ } from "../chunk-7SBI6PGB.js";
11
11
  import "../chunk-KQ4UL2WX.js";
12
12
  import "../chunk-DGUM43GV.js";
13
13
  export {
@@ -22326,11 +22326,19 @@ declare class JobWorker {
22326
22326
  private _pollTimer;
22327
22327
  private _inFlightActivation;
22328
22328
  private _log;
22329
+ private _startGate;
22329
22330
  constructor(client: CamundaClient, cfg: JobWorkerConfig);
22330
22331
  get name(): string;
22331
22332
  get activeJobs(): number;
22332
22333
  get stopped(): boolean;
22334
+ /**
22335
+ * Begin polling for jobs. Safe to call at any point: the request is buffered
22336
+ * until the transport is ready, and redundant calls (including an explicit
22337
+ * call on an `autoStart` worker) are dropped rather than starting a second
22338
+ * poll loop. Once the worker is stopped, `start()` is a no-op.
22339
+ */
22333
22340
  start(): void;
22341
+ private _beginPolling;
22334
22342
  stop(): void;
22335
22343
  /**
22336
22344
  * Gracefully stop the worker: prevent new polls, allow any in-flight activation to finish
@@ -22524,6 +22532,7 @@ declare class ThreadedJobWorker {
22524
22532
  private _inFlightActivation;
22525
22533
  private _log;
22526
22534
  private _jobQueue;
22535
+ private _startGate;
22527
22536
  constructor(client: CamundaClient, pool: ThreadPool, cfg: ThreadedJobWorkerConfig);
22528
22537
  get name(): string;
22529
22538
  get activeJobs(): number;
@@ -22534,7 +22543,14 @@ declare class ThreadedJobWorker {
22534
22543
  get busyThreads(): number;
22535
22544
  /** Resolves when the shared thread pool has finished initialising. */
22536
22545
  get ready(): Promise<void>;
22546
+ /**
22547
+ * Begin polling for jobs. Safe to call at any point: the request is buffered
22548
+ * until the shared thread pool is ready, and redundant calls (including an
22549
+ * explicit call on an `autoStart` worker) are dropped rather than starting a
22550
+ * second poll loop. Once the worker is stopped, `start()` is a no-op.
22551
+ */
22537
22552
  start(): void;
22553
+ private _beginPolling;
22538
22554
  stop(): void;
22539
22555
  stopGracefully(opts?: {
22540
22556
  waitUpToMs?: number;
@@ -22326,11 +22326,19 @@ declare class JobWorker {
22326
22326
  private _pollTimer;
22327
22327
  private _inFlightActivation;
22328
22328
  private _log;
22329
+ private _startGate;
22329
22330
  constructor(client: CamundaClient, cfg: JobWorkerConfig);
22330
22331
  get name(): string;
22331
22332
  get activeJobs(): number;
22332
22333
  get stopped(): boolean;
22334
+ /**
22335
+ * Begin polling for jobs. Safe to call at any point: the request is buffered
22336
+ * until the transport is ready, and redundant calls (including an explicit
22337
+ * call on an `autoStart` worker) are dropped rather than starting a second
22338
+ * poll loop. Once the worker is stopped, `start()` is a no-op.
22339
+ */
22333
22340
  start(): void;
22341
+ private _beginPolling;
22334
22342
  stop(): void;
22335
22343
  /**
22336
22344
  * Gracefully stop the worker: prevent new polls, allow any in-flight activation to finish
@@ -22524,6 +22532,7 @@ declare class ThreadedJobWorker {
22524
22532
  private _inFlightActivation;
22525
22533
  private _log;
22526
22534
  private _jobQueue;
22535
+ private _startGate;
22527
22536
  constructor(client: CamundaClient, pool: ThreadPool, cfg: ThreadedJobWorkerConfig);
22528
22537
  get name(): string;
22529
22538
  get activeJobs(): number;
@@ -22534,7 +22543,14 @@ declare class ThreadedJobWorker {
22534
22543
  get busyThreads(): number;
22535
22544
  /** Resolves when the shared thread pool has finished initialising. */
22536
22545
  get ready(): Promise<void>;
22546
+ /**
22547
+ * Begin polling for jobs. Safe to call at any point: the request is buffered
22548
+ * until the shared thread pool is ready, and redundant calls (including an
22549
+ * explicit call on an `autoStart` worker) are dropped rather than starting a
22550
+ * second poll loop. Once the worker is stopped, `start()` is a no-op.
22551
+ */
22537
22552
  start(): void;
22553
+ private _beginPolling;
22538
22554
  stop(): void;
22539
22555
  stopGracefully(opts?: {
22540
22556
  waitUpToMs?: number;
package/dist/index.cjs CHANGED
@@ -13060,7 +13060,7 @@ function createLogger(opts = {}) {
13060
13060
  }
13061
13061
 
13062
13062
  // src/runtime/version.ts
13063
- var packageVersion = "10.0.0-alpha.20";
13063
+ var packageVersion = "10.0.0-alpha.21";
13064
13064
 
13065
13065
  // src/runtime/supportLogger.ts
13066
13066
  var NoopSupportLogger = class {
@@ -14298,6 +14298,50 @@ function createVariableSearchFetchPage(params) {
14298
14298
  };
14299
14299
  }
14300
14300
 
14301
+ // src/runtime/workerStartGate.ts
14302
+ var WorkerStartGate = class {
14303
+ /**
14304
+ * @param transportReady Resolves when the worker's transport can service polls.
14305
+ * @param isStopped Reports whether the worker was stopped while the gate was buffering.
14306
+ */
14307
+ constructor(_transportReady, _isStopped) {
14308
+ this._transportReady = _transportReady;
14309
+ this._isStopped = _isStopped;
14310
+ }
14311
+ _transportReady;
14312
+ _isStopped;
14313
+ _requested = false;
14314
+ /** True once a start request has been accepted and not since released. */
14315
+ get requested() {
14316
+ return this._requested;
14317
+ }
14318
+ /**
14319
+ * Record a start request.
14320
+ *
14321
+ * The first accepted request invokes `onReady` once the transport resolves,
14322
+ * and only if the worker has not been stopped in the meantime. If the
14323
+ * transport fails to come up, `onError` is invoked and the gate is released so
14324
+ * a later `start()` can retry.
14325
+ *
14326
+ * @returns `false` when the request was dropped as redundant.
14327
+ */
14328
+ request(onReady, onError) {
14329
+ if (this._requested) return false;
14330
+ this._requested = true;
14331
+ void this._transportReady().then(
14332
+ () => {
14333
+ if (this._isStopped()) return;
14334
+ onReady();
14335
+ },
14336
+ (err) => {
14337
+ this._requested = false;
14338
+ onError(err);
14339
+ }
14340
+ );
14341
+ return true;
14342
+ }
14343
+ };
14344
+
14301
14345
  // src/runtime/jobWorker.ts
14302
14346
  var JobActionReceipt = "JOB_ACTION_RECEIPT";
14303
14347
  var _workerCounter = 0;
@@ -14314,6 +14358,7 @@ var JobWorker = class {
14314
14358
  _inFlightActivation = null;
14315
14359
  // CancelablePromise-like
14316
14360
  _log;
14361
+ _startGate;
14317
14362
  constructor(client2, cfg) {
14318
14363
  this._client = client2;
14319
14364
  this._cfg = {
@@ -14334,6 +14379,10 @@ var JobWorker = class {
14334
14379
  { maxBackoffTimeMs: cfg.maxBackoffTimeMs }
14335
14380
  ]);
14336
14381
  }
14382
+ this._startGate = new WorkerStartGate(
14383
+ () => Promise.resolve(),
14384
+ () => this._stopped
14385
+ );
14337
14386
  if (this._cfg.autoStart) this.start();
14338
14387
  }
14339
14388
  get name() {
@@ -14345,10 +14394,25 @@ var JobWorker = class {
14345
14394
  get stopped() {
14346
14395
  return this._stopped;
14347
14396
  }
14397
+ /**
14398
+ * Begin polling for jobs. Safe to call at any point: the request is buffered
14399
+ * until the transport is ready, and redundant calls (including an explicit
14400
+ * call on an `autoStart` worker) are dropped rather than starting a second
14401
+ * poll loop. Once the worker is stopped, `start()` is a no-op.
14402
+ */
14348
14403
  start() {
14349
14404
  if (this._stopped) return;
14350
- if (this._pollTimer) return;
14405
+ const accepted = this._startGate.request(
14406
+ () => this._beginPolling(),
14407
+ (err) => this._log.error("worker.start.transportError", err)
14408
+ );
14409
+ if (!accepted) {
14410
+ this._log.debug("worker.start.alreadyRequested");
14411
+ return;
14412
+ }
14351
14413
  this._log.info("worker.start");
14414
+ }
14415
+ _beginPolling() {
14352
14416
  const jitterMax = this._cfg.startupJitterMaxSeconds ?? 0;
14353
14417
  if (jitterMax > 0) {
14354
14418
  const jitterMs = Math.floor(Math.random() * jitterMax * 1e3);
@@ -14607,6 +14671,7 @@ var ThreadedJobWorker = class {
14607
14671
  _inFlightActivation = null;
14608
14672
  _log;
14609
14673
  _jobQueue = [];
14674
+ _startGate;
14610
14675
  constructor(client2, pool, cfg) {
14611
14676
  this._client = client2;
14612
14677
  this._pool = pool;
@@ -14623,6 +14688,10 @@ var ThreadedJobWorker = class {
14623
14688
  this._name = cfg.workerName || `threaded-worker-${cfg.jobType}-${++_workerCounter2}`;
14624
14689
  this._log = this._client.logger().scope(`worker:${this._name}`);
14625
14690
  this._pool.onThreadReady = () => this._drainQueue();
14691
+ this._startGate = new WorkerStartGate(
14692
+ () => this._pool.ready,
14693
+ () => this._stopped
14694
+ );
14626
14695
  if (this._cfg.autoStart) this.start();
14627
14696
  }
14628
14697
  get name() {
@@ -14646,10 +14715,25 @@ var ThreadedJobWorker = class {
14646
14715
  get ready() {
14647
14716
  return this._pool.ready;
14648
14717
  }
14718
+ /**
14719
+ * Begin polling for jobs. Safe to call at any point: the request is buffered
14720
+ * until the shared thread pool is ready, and redundant calls (including an
14721
+ * explicit call on an `autoStart` worker) are dropped rather than starting a
14722
+ * second poll loop. Once the worker is stopped, `start()` is a no-op.
14723
+ */
14649
14724
  start() {
14650
14725
  if (this._stopped) return;
14651
- if (this._pollTimer) return;
14726
+ const accepted = this._startGate.request(
14727
+ () => this._beginPolling(),
14728
+ (err) => this._log.error("worker.start.transportError", err)
14729
+ );
14730
+ if (!accepted) {
14731
+ this._log.debug("worker.start.alreadyRequested");
14732
+ return;
14733
+ }
14652
14734
  this._log.info("worker.start");
14735
+ }
14736
+ _beginPolling() {
14653
14737
  const jitterMax = this._cfg.startupJitterMaxSeconds ?? 0;
14654
14738
  if (jitterMax > 0) {
14655
14739
  const jitterMs = Math.floor(Math.random() * jitterMax * 1e3);