@cadenza.io/service 2.19.0 → 2.20.0
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/{Cadenza-DCMs7q97.d.mts → Cadenza-D787NzXY.d.mts} +1 -0
- package/dist/{Cadenza-DCMs7q97.d.ts → Cadenza-D787NzXY.d.ts} +1 -0
- package/dist/browser/index.js +236 -26
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +236 -26
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +236 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +236 -26
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt/index.d.mts +2 -2
- package/dist/nuxt/index.d.ts +2 -2
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/vue/index.d.mts +2 -2
- package/dist/vue/index.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _cadenza_io_core from '@cadenza.io/core';
|
|
2
2
|
import { Actor, AnyObject } from '@cadenza.io/core';
|
|
3
3
|
export { Actor, ActorConsistencyProfileName, ActorDefinition, ActorFactoryOptions, ActorInvocationOptions, ActorKeyDefinition, ActorKind, ActorLoadPolicy, ActorRuntimeReadGuard, ActorSpec, ActorStateDefinition, ActorStateReducer, ActorStateStore, ActorTaskBindingDefinition, ActorTaskBindingOptions, ActorTaskContext, ActorTaskHandler, ActorTaskMode, ActorWriteContract, AnyObject, DebounceOptions, DebounceTask, EphemeralTask, EphemeralTaskOptions, GraphRoutine, IdempotencyPolicy, RetryPolicy, RuntimeValidationPolicy, RuntimeValidationScope, SessionPolicy, SignalDefinitionInput, SignalDeliveryMode, SignalMetadata, SignalReceiverFilter, Task, TaskFunction, TaskOptions, ThrottleTagGetter } from '@cadenza.io/core';
|
|
4
|
-
import { D as DatabaseSchemaDefinition, S as ServerOptions, a as DatabaseOptions, b as DbOperationPayload, J as JoinDefinition, c as SubOperation, d as DistributedInquiryOptions, H as HydrationOptions, B as BootstrapOptions, C as CadenzaService, e as ServiceRegistry } from './Cadenza-
|
|
5
|
-
export { A as AUTHORITY_RUNTIME_STATUS_REPORT_INTENT, f as AggregateDefinition, g as AggregateFunction, h as AuthorityRuntimeStatusReport, i as BrowserRuntimeActorHandle, j as BrowserRuntimeActorOptions, k as BrowserRuntimeActorRuntimeState, l as BrowserRuntimeProjectionBinding, m as BrowserRuntimeServiceOptions, n as DatabaseMigrationConstraintDefinition, o as DatabaseMigrationDefinition, p as DatabaseMigrationPolicy, q as DatabaseMigrationStep, r as DatabaseTask, s as DbOperationType, t as DeputyDescriptor, u as DeputyTask, v as DistributedInquiryMeta, F as FieldDefinition, I as InquiryResponderDescriptor, w as InquiryResponderStatus, N as NetworkMode, O as OpEffect, Q as QueryMode, R as RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL, x as ResolvedBootstrapEndpoint, y as RuntimeMetricsHealthDetail, z as SecurityProfile, E as ServiceInstanceDescriptor, G as ServiceTransportConfig, K as ServiceTransportDescriptor, L as ServiceTransportProtocol, M as ServiceTransportRole, P as ServiceTransportSecurityProfile, T as SignalTransmissionTask, U as SortDirection, V as SubOperationType, W as TableDefinition, X as ValueOrSubOp, Y as buildAuthorityRuntimeStatusSignature, Z as normalizeAuthorityRuntimeStatusReport } from './Cadenza-
|
|
4
|
+
import { D as DatabaseSchemaDefinition, S as ServerOptions, a as DatabaseOptions, b as DbOperationPayload, J as JoinDefinition, c as SubOperation, d as DistributedInquiryOptions, H as HydrationOptions, B as BootstrapOptions, C as CadenzaService, e as ServiceRegistry } from './Cadenza-D787NzXY.mjs';
|
|
5
|
+
export { A as AUTHORITY_RUNTIME_STATUS_REPORT_INTENT, f as AggregateDefinition, g as AggregateFunction, h as AuthorityRuntimeStatusReport, i as BrowserRuntimeActorHandle, j as BrowserRuntimeActorOptions, k as BrowserRuntimeActorRuntimeState, l as BrowserRuntimeProjectionBinding, m as BrowserRuntimeServiceOptions, n as DatabaseMigrationConstraintDefinition, o as DatabaseMigrationDefinition, p as DatabaseMigrationPolicy, q as DatabaseMigrationStep, r as DatabaseTask, s as DbOperationType, t as DeputyDescriptor, u as DeputyTask, v as DistributedInquiryMeta, F as FieldDefinition, I as InquiryResponderDescriptor, w as InquiryResponderStatus, N as NetworkMode, O as OpEffect, Q as QueryMode, R as RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL, x as ResolvedBootstrapEndpoint, y as RuntimeMetricsHealthDetail, z as SecurityProfile, E as ServiceInstanceDescriptor, G as ServiceTransportConfig, K as ServiceTransportDescriptor, L as ServiceTransportProtocol, M as ServiceTransportRole, P as ServiceTransportSecurityProfile, T as SignalTransmissionTask, U as SortDirection, V as SubOperationType, W as TableDefinition, X as ValueOrSubOp, Y as buildAuthorityRuntimeStatusSignature, Z as normalizeAuthorityRuntimeStatusReport } from './Cadenza-D787NzXY.mjs';
|
|
6
6
|
import { Pool } from 'pg';
|
|
7
7
|
|
|
8
8
|
declare class GraphMetadataController {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _cadenza_io_core from '@cadenza.io/core';
|
|
2
2
|
import { Actor, AnyObject } from '@cadenza.io/core';
|
|
3
3
|
export { Actor, ActorConsistencyProfileName, ActorDefinition, ActorFactoryOptions, ActorInvocationOptions, ActorKeyDefinition, ActorKind, ActorLoadPolicy, ActorRuntimeReadGuard, ActorSpec, ActorStateDefinition, ActorStateReducer, ActorStateStore, ActorTaskBindingDefinition, ActorTaskBindingOptions, ActorTaskContext, ActorTaskHandler, ActorTaskMode, ActorWriteContract, AnyObject, DebounceOptions, DebounceTask, EphemeralTask, EphemeralTaskOptions, GraphRoutine, IdempotencyPolicy, RetryPolicy, RuntimeValidationPolicy, RuntimeValidationScope, SessionPolicy, SignalDefinitionInput, SignalDeliveryMode, SignalMetadata, SignalReceiverFilter, Task, TaskFunction, TaskOptions, ThrottleTagGetter } from '@cadenza.io/core';
|
|
4
|
-
import { D as DatabaseSchemaDefinition, S as ServerOptions, a as DatabaseOptions, b as DbOperationPayload, J as JoinDefinition, c as SubOperation, d as DistributedInquiryOptions, H as HydrationOptions, B as BootstrapOptions, C as CadenzaService, e as ServiceRegistry } from './Cadenza-
|
|
5
|
-
export { A as AUTHORITY_RUNTIME_STATUS_REPORT_INTENT, f as AggregateDefinition, g as AggregateFunction, h as AuthorityRuntimeStatusReport, i as BrowserRuntimeActorHandle, j as BrowserRuntimeActorOptions, k as BrowserRuntimeActorRuntimeState, l as BrowserRuntimeProjectionBinding, m as BrowserRuntimeServiceOptions, n as DatabaseMigrationConstraintDefinition, o as DatabaseMigrationDefinition, p as DatabaseMigrationPolicy, q as DatabaseMigrationStep, r as DatabaseTask, s as DbOperationType, t as DeputyDescriptor, u as DeputyTask, v as DistributedInquiryMeta, F as FieldDefinition, I as InquiryResponderDescriptor, w as InquiryResponderStatus, N as NetworkMode, O as OpEffect, Q as QueryMode, R as RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL, x as ResolvedBootstrapEndpoint, y as RuntimeMetricsHealthDetail, z as SecurityProfile, E as ServiceInstanceDescriptor, G as ServiceTransportConfig, K as ServiceTransportDescriptor, L as ServiceTransportProtocol, M as ServiceTransportRole, P as ServiceTransportSecurityProfile, T as SignalTransmissionTask, U as SortDirection, V as SubOperationType, W as TableDefinition, X as ValueOrSubOp, Y as buildAuthorityRuntimeStatusSignature, Z as normalizeAuthorityRuntimeStatusReport } from './Cadenza-
|
|
4
|
+
import { D as DatabaseSchemaDefinition, S as ServerOptions, a as DatabaseOptions, b as DbOperationPayload, J as JoinDefinition, c as SubOperation, d as DistributedInquiryOptions, H as HydrationOptions, B as BootstrapOptions, C as CadenzaService, e as ServiceRegistry } from './Cadenza-D787NzXY.js';
|
|
5
|
+
export { A as AUTHORITY_RUNTIME_STATUS_REPORT_INTENT, f as AggregateDefinition, g as AggregateFunction, h as AuthorityRuntimeStatusReport, i as BrowserRuntimeActorHandle, j as BrowserRuntimeActorOptions, k as BrowserRuntimeActorRuntimeState, l as BrowserRuntimeProjectionBinding, m as BrowserRuntimeServiceOptions, n as DatabaseMigrationConstraintDefinition, o as DatabaseMigrationDefinition, p as DatabaseMigrationPolicy, q as DatabaseMigrationStep, r as DatabaseTask, s as DbOperationType, t as DeputyDescriptor, u as DeputyTask, v as DistributedInquiryMeta, F as FieldDefinition, I as InquiryResponderDescriptor, w as InquiryResponderStatus, N as NetworkMode, O as OpEffect, Q as QueryMode, R as RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL, x as ResolvedBootstrapEndpoint, y as RuntimeMetricsHealthDetail, z as SecurityProfile, E as ServiceInstanceDescriptor, G as ServiceTransportConfig, K as ServiceTransportDescriptor, L as ServiceTransportProtocol, M as ServiceTransportRole, P as ServiceTransportSecurityProfile, T as SignalTransmissionTask, U as SortDirection, V as SubOperationType, W as TableDefinition, X as ValueOrSubOp, Y as buildAuthorityRuntimeStatusSignature, Z as normalizeAuthorityRuntimeStatusReport } from './Cadenza-D787NzXY.js';
|
|
6
6
|
import { Pool } from 'pg';
|
|
7
7
|
|
|
8
8
|
declare class GraphMetadataController {
|
package/dist/index.js
CHANGED
|
@@ -8633,6 +8633,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8633
8633
|
}
|
|
8634
8634
|
}
|
|
8635
8635
|
}
|
|
8636
|
+
const hasExplicitSignalRoutingRows = signalToTaskMaps.length > 0;
|
|
8637
|
+
const hasExplicitIntentRoutingRows = intentToTaskMaps.length > 0;
|
|
8636
8638
|
const latestManifestSnapshots = selectLatestServiceManifestSnapshots(manifestSnapshots);
|
|
8637
8639
|
const explodedManifest = explodeServiceManifestSnapshots(
|
|
8638
8640
|
latestManifestSnapshots
|
|
@@ -8713,26 +8715,30 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8713
8715
|
row.task_version ?? 1
|
|
8714
8716
|
).trim()}`
|
|
8715
8717
|
);
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
row.
|
|
8722
|
-
|
|
8723
|
-
row.
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
row.
|
|
8734
|
-
|
|
8735
|
-
|
|
8718
|
+
if (!hasExplicitSignalRoutingRows) {
|
|
8719
|
+
pushUnique(
|
|
8720
|
+
explodedManifest.signalToTaskMaps,
|
|
8721
|
+
signalToTaskMaps,
|
|
8722
|
+
seenSignalMaps,
|
|
8723
|
+
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
8724
|
+
row.service_name ?? ""
|
|
8725
|
+
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
8726
|
+
row.task_version ?? 1
|
|
8727
|
+
).trim()}`
|
|
8728
|
+
);
|
|
8729
|
+
}
|
|
8730
|
+
if (!hasExplicitIntentRoutingRows) {
|
|
8731
|
+
pushUnique(
|
|
8732
|
+
explodedManifest.intentToTaskMaps,
|
|
8733
|
+
intentToTaskMaps,
|
|
8734
|
+
seenIntentMaps,
|
|
8735
|
+
(row) => `${String(row.intent_name ?? "").trim()}|${String(
|
|
8736
|
+
row.service_name ?? ""
|
|
8737
|
+
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
8738
|
+
row.task_version ?? 1
|
|
8739
|
+
).trim()}`
|
|
8740
|
+
);
|
|
8741
|
+
}
|
|
8736
8742
|
return {
|
|
8737
8743
|
serviceInstances,
|
|
8738
8744
|
serviceInstanceTransports,
|
|
@@ -9335,16 +9341,35 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9335
9341
|
const authorityFullSyncResponderTask = CadenzaService.createMetaTask(
|
|
9336
9342
|
BOOTSTRAP_FULL_SYNC_RESPONDER_TASK_NAME,
|
|
9337
9343
|
async (ctx) => {
|
|
9344
|
+
const queryOptionalAuthorityRoutingRows = async (tableName) => {
|
|
9345
|
+
try {
|
|
9346
|
+
return await DatabaseController.instance.queryAuthorityTableRows(
|
|
9347
|
+
tableName
|
|
9348
|
+
);
|
|
9349
|
+
} catch (error) {
|
|
9350
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9351
|
+
if (message.includes(
|
|
9352
|
+
`Table '${tableName}' is not registered on the CadenzaDB PostgresActor`
|
|
9353
|
+
)) {
|
|
9354
|
+
return [];
|
|
9355
|
+
}
|
|
9356
|
+
throw error;
|
|
9357
|
+
}
|
|
9358
|
+
};
|
|
9338
9359
|
const [
|
|
9339
9360
|
serviceInstances,
|
|
9340
9361
|
serviceInstanceTransports,
|
|
9341
|
-
serviceManifests
|
|
9362
|
+
serviceManifests,
|
|
9363
|
+
signalToTaskMaps,
|
|
9364
|
+
intentToTaskMaps
|
|
9342
9365
|
] = await Promise.all([
|
|
9343
9366
|
DatabaseController.instance.queryAuthorityTableRows("service_instance"),
|
|
9344
9367
|
DatabaseController.instance.queryAuthorityTableRows(
|
|
9345
9368
|
"service_instance_transport"
|
|
9346
9369
|
),
|
|
9347
|
-
DatabaseController.instance.queryAuthorityTableRows("service_manifest")
|
|
9370
|
+
DatabaseController.instance.queryAuthorityTableRows("service_manifest"),
|
|
9371
|
+
queryOptionalAuthorityRoutingRows("signal_to_task_map"),
|
|
9372
|
+
queryOptionalAuthorityRoutingRows("intent_to_task_map")
|
|
9348
9373
|
]);
|
|
9349
9374
|
return {
|
|
9350
9375
|
...ctx,
|
|
@@ -9352,7 +9377,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9352
9377
|
...this.collectBootstrapFullSyncPayload({
|
|
9353
9378
|
serviceInstances,
|
|
9354
9379
|
serviceInstanceTransports,
|
|
9355
|
-
serviceManifests
|
|
9380
|
+
serviceManifests,
|
|
9381
|
+
signalToTaskMaps,
|
|
9382
|
+
intentToTaskMaps
|
|
9356
9383
|
})
|
|
9357
9384
|
};
|
|
9358
9385
|
},
|
|
@@ -16012,12 +16039,13 @@ var RuntimeValidationController = class _RuntimeValidationController {
|
|
|
16012
16039
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
16013
16040
|
var import_core3 = require("@cadenza.io/core");
|
|
16014
16041
|
var ACTOR_SESSION_STATE_PERSIST_CONCURRENCY = 20;
|
|
16042
|
+
var META_ACTOR_SESSION_STATE_HYDRATE_INTENT = "meta-actor-session-state-hydrate";
|
|
16015
16043
|
var ACTOR_SESSION_TRACE_ENABLED4 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
16016
16044
|
function shouldAssumeSuccessfulActorSessionRowCount(ctx) {
|
|
16017
16045
|
return ctx.__success === true && ctx.rowCount === void 0 && ctx.__status === "success" && ctx.__serviceName === "CadenzaDB" && ctx.__localTaskName === "Insert actor_session_state in CadenzaDB";
|
|
16018
16046
|
}
|
|
16019
16047
|
function registerActorSessionPersistenceTasks() {
|
|
16020
|
-
if (CadenzaService.get("Persist actor session state")) {
|
|
16048
|
+
if (CadenzaService.get("Persist actor session state") && CadenzaService.get("Hydrate actor session state")) {
|
|
16021
16049
|
return;
|
|
16022
16050
|
}
|
|
16023
16051
|
const localActorSessionTaskOptions = {
|
|
@@ -16034,6 +16062,14 @@ function registerActorSessionPersistenceTasks() {
|
|
|
16034
16062
|
isSubMeta: true
|
|
16035
16063
|
}
|
|
16036
16064
|
);
|
|
16065
|
+
const actorSessionStateQueryTask = CadenzaService.getLocalCadenzaDBQueryTask("actor_session_state") ?? CadenzaService.get("dbQueryActorSessionState") ?? CadenzaService.get("Query actor_session_state in CadenzaDB") ?? CadenzaService.createCadenzaDBQueryTask(
|
|
16066
|
+
"actor_session_state",
|
|
16067
|
+
{},
|
|
16068
|
+
{
|
|
16069
|
+
concurrency: ACTOR_SESSION_STATE_PERSIST_CONCURRENCY,
|
|
16070
|
+
isSubMeta: true
|
|
16071
|
+
}
|
|
16072
|
+
);
|
|
16037
16073
|
const validateActorSessionStatePersistenceTask = CadenzaService.createMetaTask(
|
|
16038
16074
|
"Validate actor session state persistence",
|
|
16039
16075
|
(ctx) => {
|
|
@@ -16067,6 +16103,103 @@ function registerActorSessionPersistenceTasks() {
|
|
|
16067
16103
|
const insertAndValidateActorSessionStateTask = actorSessionStateInsertTask.then(
|
|
16068
16104
|
validateActorSessionStatePersistenceTask
|
|
16069
16105
|
);
|
|
16106
|
+
const validateActorSessionStateHydrationTask = CadenzaService.createMetaTask(
|
|
16107
|
+
"Validate actor session state hydration",
|
|
16108
|
+
(ctx) => {
|
|
16109
|
+
if (ctx.errored || ctx.failed || ctx.__success !== true) {
|
|
16110
|
+
throw new Error(
|
|
16111
|
+
String(
|
|
16112
|
+
ctx.__error ?? ctx.error ?? "actor_session_state hydration query failed"
|
|
16113
|
+
)
|
|
16114
|
+
);
|
|
16115
|
+
}
|
|
16116
|
+
const row = ctx.actorSessionState && typeof ctx.actorSessionState === "object" && !Array.isArray(ctx.actorSessionState) ? ctx.actorSessionState : null;
|
|
16117
|
+
if (!row) {
|
|
16118
|
+
return {
|
|
16119
|
+
__success: true,
|
|
16120
|
+
hydrated: false
|
|
16121
|
+
};
|
|
16122
|
+
}
|
|
16123
|
+
const expiresAt = typeof row.expiresAt === "string" ? row.expiresAt : typeof row.expires_at === "string" ? row.expires_at : null;
|
|
16124
|
+
const expiresAtMs = expiresAt ? Date.parse(expiresAt) : Number.NaN;
|
|
16125
|
+
if (Number.isFinite(expiresAtMs) && expiresAtMs <= Date.now()) {
|
|
16126
|
+
return {
|
|
16127
|
+
__success: true,
|
|
16128
|
+
hydrated: false
|
|
16129
|
+
};
|
|
16130
|
+
}
|
|
16131
|
+
const durableState = row.durableState ?? row.durable_state ?? null;
|
|
16132
|
+
const durableVersion = Number(
|
|
16133
|
+
row.durableVersion ?? row.durable_version ?? Number.NaN
|
|
16134
|
+
);
|
|
16135
|
+
if (typeof durableState !== "object" || durableState === null || Array.isArray(durableState)) {
|
|
16136
|
+
throw new Error("actor_session_state durable_state must be a non-null object");
|
|
16137
|
+
}
|
|
16138
|
+
if (!Number.isInteger(durableVersion) || durableVersion < 0) {
|
|
16139
|
+
throw new Error(
|
|
16140
|
+
"actor_session_state durable_version must be a non-negative integer"
|
|
16141
|
+
);
|
|
16142
|
+
}
|
|
16143
|
+
return {
|
|
16144
|
+
__success: true,
|
|
16145
|
+
hydrated: true,
|
|
16146
|
+
actor_name: row.actorName ?? row.actor_name,
|
|
16147
|
+
actor_version: row.actorVersion ?? row.actor_version,
|
|
16148
|
+
actor_key: row.actorKey ?? row.actor_key,
|
|
16149
|
+
service_name: row.serviceName ?? row.service_name,
|
|
16150
|
+
durable_state: durableState,
|
|
16151
|
+
durable_version: durableVersion
|
|
16152
|
+
};
|
|
16153
|
+
},
|
|
16154
|
+
"Validates and normalizes hydrated actor_session_state rows.",
|
|
16155
|
+
localActorSessionTaskOptions
|
|
16156
|
+
);
|
|
16157
|
+
const queryAndValidateActorSessionStateTask = actorSessionStateQueryTask.then(
|
|
16158
|
+
validateActorSessionStateHydrationTask
|
|
16159
|
+
);
|
|
16160
|
+
CadenzaService.createMetaTask(
|
|
16161
|
+
"Hydrate actor session state",
|
|
16162
|
+
(ctx) => {
|
|
16163
|
+
const actorName = typeof ctx.actor_name === "string" ? ctx.actor_name.trim() : "";
|
|
16164
|
+
const actorKey = typeof ctx.actor_key === "string" ? ctx.actor_key.trim() : "";
|
|
16165
|
+
const actorVersion = Number(ctx.actor_version ?? 1);
|
|
16166
|
+
const serviceName = CadenzaService.serviceRegistry.serviceName;
|
|
16167
|
+
if (!actorName) {
|
|
16168
|
+
throw new Error("actor_name is required for actor session hydration");
|
|
16169
|
+
}
|
|
16170
|
+
if (!actorKey) {
|
|
16171
|
+
throw new Error("actor_key is required for actor session hydration");
|
|
16172
|
+
}
|
|
16173
|
+
if (!Number.isInteger(actorVersion) || actorVersion < 1) {
|
|
16174
|
+
throw new Error("actor_version must be a positive integer");
|
|
16175
|
+
}
|
|
16176
|
+
if (!serviceName) {
|
|
16177
|
+
throw new Error("service_name is not available for actor session hydration");
|
|
16178
|
+
}
|
|
16179
|
+
return {
|
|
16180
|
+
...ctx,
|
|
16181
|
+
actor_name: actorName,
|
|
16182
|
+
actor_key: actorKey,
|
|
16183
|
+
actor_version: actorVersion,
|
|
16184
|
+
service_name: serviceName,
|
|
16185
|
+
queryData: {
|
|
16186
|
+
filter: {
|
|
16187
|
+
actor_name: actorName,
|
|
16188
|
+
actor_version: actorVersion,
|
|
16189
|
+
actor_key: actorKey,
|
|
16190
|
+
service_name: serviceName,
|
|
16191
|
+
deleted: false
|
|
16192
|
+
},
|
|
16193
|
+
queryMode: "one",
|
|
16194
|
+
sort: {
|
|
16195
|
+
updated: "desc"
|
|
16196
|
+
}
|
|
16197
|
+
}
|
|
16198
|
+
};
|
|
16199
|
+
},
|
|
16200
|
+
"Builds a one-row actor_session_state lookup for lazy actor hydration.",
|
|
16201
|
+
localActorSessionTaskOptions
|
|
16202
|
+
).then(queryAndValidateActorSessionStateTask).respondsTo(META_ACTOR_SESSION_STATE_HYDRATE_INTENT);
|
|
16070
16203
|
CadenzaService.createMetaTask(
|
|
16071
16204
|
"Persist actor session state",
|
|
16072
16205
|
(ctx) => {
|
|
@@ -20167,6 +20300,10 @@ function resolveInquiryFailureError(inquiry, value, depth = 3, seen = /* @__PURE
|
|
|
20167
20300
|
}
|
|
20168
20301
|
return `Inquiry '${inquiry}' did not complete successfully`;
|
|
20169
20302
|
}
|
|
20303
|
+
function normalizePositiveInteger2(value, fallback) {
|
|
20304
|
+
const normalized = Number(value);
|
|
20305
|
+
return Number.isInteger(normalized) && normalized > 0 ? normalized : fallback;
|
|
20306
|
+
}
|
|
20170
20307
|
var DEFAULT_DEPUTY_TASK_CONCURRENCY = 50;
|
|
20171
20308
|
var DEFAULT_DEPUTY_TASK_TIMEOUT_MS = 12e4;
|
|
20172
20309
|
var DEFAULT_DATABASE_PROXY_TASK_CONCURRENCY = 50;
|
|
@@ -22000,11 +22137,84 @@ var CadenzaService = class {
|
|
|
22000
22137
|
}
|
|
22001
22138
|
static createActor(spec, options = {}) {
|
|
22002
22139
|
this.bootstrap();
|
|
22003
|
-
return import_core5.default.createActor(
|
|
22140
|
+
return import_core5.default.createActor(
|
|
22141
|
+
spec,
|
|
22142
|
+
this.withActorSessionHydration(
|
|
22143
|
+
spec,
|
|
22144
|
+
options
|
|
22145
|
+
)
|
|
22146
|
+
);
|
|
22004
22147
|
}
|
|
22005
22148
|
static createActorFromDefinition(definition, options = {}) {
|
|
22006
22149
|
this.bootstrap();
|
|
22007
|
-
return import_core5.default.createActorFromDefinition(
|
|
22150
|
+
return import_core5.default.createActorFromDefinition(
|
|
22151
|
+
definition,
|
|
22152
|
+
this.withActorSessionHydration(
|
|
22153
|
+
{
|
|
22154
|
+
name: definition.name,
|
|
22155
|
+
description: definition.description,
|
|
22156
|
+
defaultKey: definition.defaultKey,
|
|
22157
|
+
kind: definition.kind,
|
|
22158
|
+
loadPolicy: definition.loadPolicy,
|
|
22159
|
+
writeContract: definition.writeContract,
|
|
22160
|
+
consistencyProfile: definition.consistencyProfile,
|
|
22161
|
+
retry: definition.retry,
|
|
22162
|
+
idempotency: definition.idempotency,
|
|
22163
|
+
session: definition.session,
|
|
22164
|
+
runtimeReadGuard: definition.runtimeReadGuard,
|
|
22165
|
+
key: definition.key,
|
|
22166
|
+
state: definition.state,
|
|
22167
|
+
taskBindings: definition.tasks,
|
|
22168
|
+
initState: definition.state?.durable?.initState ?? definition.state?.durable?.initialState
|
|
22169
|
+
},
|
|
22170
|
+
options
|
|
22171
|
+
)
|
|
22172
|
+
);
|
|
22173
|
+
}
|
|
22174
|
+
static withActorSessionHydration(spec, options) {
|
|
22175
|
+
if (options.hydrateDurableState || spec.session?.persistDurableState !== true) {
|
|
22176
|
+
return options;
|
|
22177
|
+
}
|
|
22178
|
+
const actorName = String(spec.name ?? "").trim();
|
|
22179
|
+
const actorVersion = 1;
|
|
22180
|
+
const timeoutMs = normalizePositiveInteger2(
|
|
22181
|
+
spec.session?.persistenceTimeoutMs,
|
|
22182
|
+
5e3
|
|
22183
|
+
);
|
|
22184
|
+
return {
|
|
22185
|
+
...options,
|
|
22186
|
+
hydrateDurableState: async (actorKey) => {
|
|
22187
|
+
registerActorSessionPersistenceTasks();
|
|
22188
|
+
const response = await import_core5.default.inquire(
|
|
22189
|
+
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
22190
|
+
{
|
|
22191
|
+
actor_name: actorName,
|
|
22192
|
+
actor_version: actorVersion,
|
|
22193
|
+
actor_key: actorKey
|
|
22194
|
+
},
|
|
22195
|
+
{
|
|
22196
|
+
timeout: timeoutMs,
|
|
22197
|
+
requireComplete: true,
|
|
22198
|
+
rejectOnTimeout: true
|
|
22199
|
+
}
|
|
22200
|
+
);
|
|
22201
|
+
if (!response || typeof response !== "object" || response.__success !== true) {
|
|
22202
|
+
throw new Error(
|
|
22203
|
+
resolveInquiryFailureError(
|
|
22204
|
+
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
22205
|
+
response
|
|
22206
|
+
)
|
|
22207
|
+
);
|
|
22208
|
+
}
|
|
22209
|
+
if (response.hydrated !== true) {
|
|
22210
|
+
return null;
|
|
22211
|
+
}
|
|
22212
|
+
return {
|
|
22213
|
+
durableState: response.durable_state,
|
|
22214
|
+
durableVersion: Number(response.durable_version)
|
|
22215
|
+
};
|
|
22216
|
+
}
|
|
22217
|
+
};
|
|
22008
22218
|
}
|
|
22009
22219
|
/**
|
|
22010
22220
|
* Creates and registers a new task with the provided name, function, and optional details.
|