@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.d.mts
CHANGED
|
@@ -2155,6 +2155,8 @@ declare class Actor<D extends Record<string, any> = AnyObject, R = AnyObject> {
|
|
|
2155
2155
|
private resolveInitialRuntimeState;
|
|
2156
2156
|
private ensureStateRecord;
|
|
2157
2157
|
private touchSession;
|
|
2158
|
+
private pruneExpiredActorKeys;
|
|
2159
|
+
private isSessionExpired;
|
|
2158
2160
|
private runWithOptionalIdempotency;
|
|
2159
2161
|
private runWithPerKeyWriteSerialization;
|
|
2160
2162
|
private getActiveIdempotencyRecord;
|
package/dist/index.d.ts
CHANGED
|
@@ -2155,6 +2155,8 @@ declare class Actor<D extends Record<string, any> = AnyObject, R = AnyObject> {
|
|
|
2155
2155
|
private resolveInitialRuntimeState;
|
|
2156
2156
|
private ensureStateRecord;
|
|
2157
2157
|
private touchSession;
|
|
2158
|
+
private pruneExpiredActorKeys;
|
|
2159
|
+
private isSessionExpired;
|
|
2158
2160
|
private runWithOptionalIdempotency;
|
|
2159
2161
|
private runWithPerKeyWriteSerialization;
|
|
2160
2162
|
private getActiveIdempotencyRecord;
|
package/dist/index.js
CHANGED
|
@@ -3927,7 +3927,9 @@ var Actor = class {
|
|
|
3927
3927
|
bindingOptions.touchSession
|
|
3928
3928
|
);
|
|
3929
3929
|
const actorKey = this.resolveActorKey(normalizedInput, invocationOptions);
|
|
3930
|
-
|
|
3930
|
+
const now2 = Date.now();
|
|
3931
|
+
this.pruneExpiredActorKeys(now2);
|
|
3932
|
+
this.touchSession(actorKey, invocationOptions.touchSession, now2);
|
|
3931
3933
|
const runTask = async () => {
|
|
3932
3934
|
const stateRecord = this.ensureStateRecord(actorKey);
|
|
3933
3935
|
stateRecord.lastReadAt = Date.now();
|
|
@@ -4098,6 +4100,7 @@ var Actor = class {
|
|
|
4098
4100
|
*/
|
|
4099
4101
|
getDurableState(actorKey) {
|
|
4100
4102
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4103
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4101
4104
|
return cloneForDurableState(this.ensureStateRecord(key).durableState);
|
|
4102
4105
|
}
|
|
4103
4106
|
/**
|
|
@@ -4105,6 +4108,7 @@ var Actor = class {
|
|
|
4105
4108
|
*/
|
|
4106
4109
|
getRuntimeState(actorKey) {
|
|
4107
4110
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4111
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4108
4112
|
return this.ensureStateRecord(key).runtimeState;
|
|
4109
4113
|
}
|
|
4110
4114
|
/**
|
|
@@ -4118,6 +4122,7 @@ var Actor = class {
|
|
|
4118
4122
|
*/
|
|
4119
4123
|
getDurableVersion(actorKey) {
|
|
4120
4124
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4125
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4121
4126
|
return this.ensureStateRecord(key).version;
|
|
4122
4127
|
}
|
|
4123
4128
|
/**
|
|
@@ -4125,6 +4130,7 @@ var Actor = class {
|
|
|
4125
4130
|
*/
|
|
4126
4131
|
getRuntimeVersion(actorKey) {
|
|
4127
4132
|
const key = normalizeActorKey(actorKey) ?? this.spec.defaultKey;
|
|
4133
|
+
this.pruneExpiredActorKeys(Date.now());
|
|
4128
4134
|
return this.ensureStateRecord(key).runtimeVersion;
|
|
4129
4135
|
}
|
|
4130
4136
|
/**
|
|
@@ -4295,6 +4301,30 @@ var Actor = class {
|
|
|
4295
4301
|
existing.absoluteExpiresAt = touchedAt + absoluteTtlMs;
|
|
4296
4302
|
}
|
|
4297
4303
|
}
|
|
4304
|
+
pruneExpiredActorKeys(now2) {
|
|
4305
|
+
if (!this.spec.session?.enabled || this.sessionByKey.size === 0) {
|
|
4306
|
+
return;
|
|
4307
|
+
}
|
|
4308
|
+
for (const [actorKey, session] of this.sessionByKey.entries()) {
|
|
4309
|
+
if (!this.isSessionExpired(session, now2)) {
|
|
4310
|
+
continue;
|
|
4311
|
+
}
|
|
4312
|
+
if (this.writeQueueByKey.has(actorKey)) {
|
|
4313
|
+
continue;
|
|
4314
|
+
}
|
|
4315
|
+
this.stateByKey.delete(actorKey);
|
|
4316
|
+
this.sessionByKey.delete(actorKey);
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
isSessionExpired(session, now2) {
|
|
4320
|
+
if (session.absoluteExpiresAt !== null && now2 >= session.absoluteExpiresAt) {
|
|
4321
|
+
return true;
|
|
4322
|
+
}
|
|
4323
|
+
if (session.idleExpiresAt !== null && now2 >= session.idleExpiresAt) {
|
|
4324
|
+
return true;
|
|
4325
|
+
}
|
|
4326
|
+
return false;
|
|
4327
|
+
}
|
|
4298
4328
|
runWithOptionalIdempotency(taskBindingId, actorKey, options, runTask) {
|
|
4299
4329
|
const idempotencyPolicy = this.spec.idempotency;
|
|
4300
4330
|
const enabled = idempotencyPolicy?.enabled ?? false;
|