@cadenza.io/core 3.26.0 → 3.26.1
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/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3887,7 +3887,9 @@ var Actor = class {
|
|
|
3887
3887
|
bindingOptions.touchSession
|
|
3888
3888
|
);
|
|
3889
3889
|
const actorKey = this.resolveActorKey(normalizedInput, invocationOptions);
|
|
3890
|
-
|
|
3890
|
+
const now2 = Date.now();
|
|
3891
|
+
this.pruneExpiredActorKeys(now2);
|
|
3892
|
+
this.touchSession(actorKey, invocationOptions.touchSession, now2);
|
|
3891
3893
|
const runTask = async () => {
|
|
3892
3894
|
const stateRecord = this.ensureStateRecord(actorKey);
|
|
3893
3895
|
stateRecord.lastReadAt = Date.now();
|
|
@@ -4058,6 +4060,7 @@ var Actor = class {
|
|
|
4058
4060
|
*/
|
|
4059
4061
|
getDurableState(actorKey) {
|
|
4060
4062
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4063
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4061
4064
|
return cloneForDurableState(this.ensureStateRecord(key).durableState);
|
|
4062
4065
|
}
|
|
4063
4066
|
/**
|
|
@@ -4065,6 +4068,7 @@ var Actor = class {
|
|
|
4065
4068
|
*/
|
|
4066
4069
|
getRuntimeState(actorKey) {
|
|
4067
4070
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4071
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4068
4072
|
return this.ensureStateRecord(key).runtimeState;
|
|
4069
4073
|
}
|
|
4070
4074
|
/**
|
|
@@ -4078,6 +4082,7 @@ var Actor = class {
|
|
|
4078
4082
|
*/
|
|
4079
4083
|
getDurableVersion(actorKey) {
|
|
4080
4084
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4085
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4081
4086
|
return this.ensureStateRecord(key).version;
|
|
4082
4087
|
}
|
|
4083
4088
|
/**
|
|
@@ -4085,6 +4090,7 @@ var Actor = class {
|
|
|
4085
4090
|
*/
|
|
4086
4091
|
getRuntimeVersion(actorKey) {
|
|
4087
4092
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4093
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4088
4094
|
return this.ensureStateRecord(key).runtimeVersion;
|
|
4089
4095
|
}
|
|
4090
4096
|
/**
|
|
@@ -4255,6 +4261,30 @@ var Actor = class {
|
|
|
4255
4261
|
existing.absoluteExpiresAt = touchedAt + absoluteTtlMs;
|
|
4256
4262
|
}
|
|
4257
4263
|
}
|
|
4264
|
+
pruneExpiredActorKeys(now2) {
|
|
4265
|
+
if (!this.spec.session?.enabled || this.sessionByKey.size === 0) {
|
|
4266
|
+
return;
|
|
4267
|
+
}
|
|
4268
|
+
for (const [actorKey, session] of this.sessionByKey.entries()) {
|
|
4269
|
+
if (!this.isSessionExpired(session, now2)) {
|
|
4270
|
+
continue;
|
|
4271
|
+
}
|
|
4272
|
+
if (this.writeQueueByKey.has(actorKey)) {
|
|
4273
|
+
continue;
|
|
4274
|
+
}
|
|
4275
|
+
this.stateByKey.delete(actorKey);
|
|
4276
|
+
this.sessionByKey.delete(actorKey);
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
isSessionExpired(session, now2) {
|
|
4280
|
+
if (session.absoluteExpiresAt !== null && now2 >= session.absoluteExpiresAt) {
|
|
4281
|
+
return true;
|
|
4282
|
+
}
|
|
4283
|
+
if (session.idleExpiresAt !== null && now2 >= session.idleExpiresAt) {
|
|
4284
|
+
return true;
|
|
4285
|
+
}
|
|
4286
|
+
return false;
|
|
4287
|
+
}
|
|
4258
4288
|
runWithOptionalIdempotency(taskBindingId, actorKey, options, runTask) {
|
|
4259
4289
|
const idempotencyPolicy = this.spec.idempotency;
|
|
4260
4290
|
const enabled = idempotencyPolicy?.enabled ?? false;
|