@cadenza.io/service 2.21.1 → 2.21.2

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.
@@ -375,6 +375,7 @@ declare class ServiceRegistry {
375
375
  private authorityBootstrapHandshakeRetryIndex;
376
376
  private authorityBootstrapHandshakeRetryGeneration;
377
377
  private authorityBootstrapHandshakeRetryReason;
378
+ private authorityBootstrapRecoveryActive;
378
379
  handleInstanceUpdateTask: Task;
379
380
  handleTransportUpdateTask: Task;
380
381
  handleGlobalSignalRegistrationTask: Task;
@@ -375,6 +375,7 @@ declare class ServiceRegistry {
375
375
  private authorityBootstrapHandshakeRetryIndex;
376
376
  private authorityBootstrapHandshakeRetryGeneration;
377
377
  private authorityBootstrapHandshakeRetryReason;
378
+ private authorityBootstrapRecoveryActive;
378
379
  handleInstanceUpdateTask: Task;
379
380
  handleTransportUpdateTask: Task;
380
381
  handleGlobalSignalRegistrationTask: Task;
@@ -294,6 +294,16 @@ var DELEGATION_FAILURE_CONTEXT_KEYS = [
294
294
  "transportProtocols",
295
295
  "transportProtocol"
296
296
  ];
297
+ var ACTOR_SESSION_STATE_REMOTE_ROUTINE = "Insert actor_session_state";
298
+ var ACTOR_SESSION_SNAPSHOT_ROOT_KEYS = [
299
+ "__remoteRoutineName",
300
+ "__serviceName",
301
+ "__localTaskName",
302
+ "__localTaskVersion",
303
+ "__localServiceName",
304
+ "__timeout",
305
+ ...ROOT_METADATA_PASSTHROUGH_KEYS
306
+ ];
297
307
  function isPlainObject(value) {
298
308
  if (!value || typeof value !== "object" || Array.isArray(value)) {
299
309
  return false;
@@ -318,6 +328,9 @@ function cloneDelegationValue(value) {
318
328
  return value;
319
329
  }
320
330
  function buildDelegationRequestSnapshot(context) {
331
+ if (typeof context.__remoteRoutineName === "string" && context.__remoteRoutineName.trim() === ACTOR_SESSION_STATE_REMOTE_ROUTINE) {
332
+ return buildActorSessionDelegationSnapshot(context);
333
+ }
321
334
  const snapshot = {};
322
335
  for (const [key, value] of Object.entries(context)) {
323
336
  if (key === DELEGATION_REQUEST_SNAPSHOT_KEY || key === "task" || key === "routine") {
@@ -327,6 +340,21 @@ function buildDelegationRequestSnapshot(context) {
327
340
  }
328
341
  return snapshot;
329
342
  }
343
+ function buildActorSessionDelegationSnapshot(context) {
344
+ const snapshot = {};
345
+ for (const key of ACTOR_SESSION_SNAPSHOT_ROOT_KEYS) {
346
+ if (context[key] !== void 0) {
347
+ snapshot[key] = cloneDelegationValue(context[key]);
348
+ }
349
+ }
350
+ if (context.data !== void 0) {
351
+ snapshot.data = cloneDelegationValue(context.data);
352
+ }
353
+ if (context.queryData !== void 0) {
354
+ snapshot.queryData = cloneDelegationValue(context.queryData);
355
+ }
356
+ return snapshot;
357
+ }
330
358
  function hoistDelegationMetadataFields(input, metadataInput) {
331
359
  const context = input && typeof input === "object" ? { ...input } : {};
332
360
  const mutableContext = context;
@@ -4153,6 +4181,7 @@ var ServiceRegistry = class _ServiceRegistry {
4153
4181
  this.authorityBootstrapHandshakeRetryIndex = 0;
4154
4182
  this.authorityBootstrapHandshakeRetryGeneration = 0;
4155
4183
  this.authorityBootstrapHandshakeRetryReason = null;
4184
+ this.authorityBootstrapRecoveryActive = false;
4156
4185
  this.authorityFullSyncResponderTask = null;
4157
4186
  this.authorityServiceCommunicationPersistenceTask = null;
4158
4187
  this.localLifecycleFlushActor = CadenzaService.createActor(
@@ -4727,6 +4756,9 @@ var ServiceRegistry = class _ServiceRegistry {
4727
4756
  if (serviceName === "CadenzaDB" && (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure)) {
4728
4757
  return false;
4729
4758
  }
4759
+ if (serviceName === "CadenzaDB" && this.authorityBootstrapRecoveryActive) {
4760
+ return false;
4761
+ }
4730
4762
  const serviceInstances = this.instances.get(serviceName);
4731
4763
  const instances = serviceInstances?.filter((instance) => {
4732
4764
  if (serviceInstanceId && instance.uuid === serviceInstanceId) {
@@ -5019,6 +5051,9 @@ var ServiceRegistry = class _ServiceRegistry {
5019
5051
  return false;
5020
5052
  }
5021
5053
  }
5054
+ if (this.authorityBootstrapRecoveryActive) {
5055
+ return false;
5056
+ }
5022
5057
  this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
5023
5058
  return true;
5024
5059
  },
@@ -7700,6 +7735,7 @@ var ServiceRegistry = class _ServiceRegistry {
7700
7735
  this.clearAuthorityBootstrapHandshakeRetryTimer();
7701
7736
  this.authorityBootstrapHandshakeRetryIndex = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length;
7702
7737
  this.authorityBootstrapHandshakeRetryReason = null;
7738
+ this.authorityBootstrapRecoveryActive = false;
7703
7739
  }
7704
7740
  buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(baseDelayMs, attempt) {
7705
7741
  return buildDeterministicJitteredDelayMs(
@@ -7756,6 +7792,13 @@ var ServiceRegistry = class _ServiceRegistry {
7756
7792
  return this.scheduleAuthorityBootstrapHandshakeRetry(reason);
7757
7793
  }
7758
7794
  restartAuthorityBootstrapRecovery(reason) {
7795
+ if (this.authorityBootstrapRecoveryActive) {
7796
+ if (typeof reason === "string" && reason.trim()) {
7797
+ this.authorityBootstrapHandshakeRetryReason = reason.trim();
7798
+ }
7799
+ return false;
7800
+ }
7801
+ this.authorityBootstrapRecoveryActive = true;
7759
7802
  this.invalidateAuthorityBootstrapHandshake();
7760
7803
  this.invalidateBootstrapFullSyncRetryState(reason);
7761
7804
  return this.restartAuthorityBootstrapHandshakeRetryChain(reason);