@zlink-systems/framework 0.28.0 → 0.29.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/.tsbuildinfo +1 -1
- package/dist/contracts/Configuration/Builders.d.ts +2 -0
- package/dist/contracts/Configuration/InternalDefaults.d.ts +3 -0
- package/dist/contracts/Configuration/InternalDefaults.js +4 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +9 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.d.ts +1 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.js +16 -0
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +3 -0
- package/dist/runtime/actors/actor-mailbox.d.ts +2 -2
- package/dist/runtime/actors/actor-mailbox.js +2 -2
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +1 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +12 -3
- package/dist/runtime/execution/serial-execution-queue.js +116 -28
- package/dist/runtime/foundation/operation-registry.d.ts +3 -2
- package/dist/runtime/foundation/operation-registry.js +5 -1
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +0 -2
- package/dist/runtime/foundation/service-authority-payload-codec.js +0 -43
- package/dist/runtime/foundation/service-stateful-registry.d.ts +4 -3
- package/dist/runtime/foundation/service-stateful-registry.js +5 -2
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +1 -8
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -11
- package/dist/runtime/foundation/service-stateful-wire-codec.js +1 -23
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -0
- package/dist/runtime/foundation/service-topology-registry.js +16 -17
- package/dist/runtime/host/instance-activation-authority.d.ts +0 -1
- package/dist/runtime/host/instance-activation-authority.js +46 -97
- package/dist/runtime/host/spot-address-transport.js +1 -1
- package/dist/runtime/host/stateful-authority-route-runtime.d.ts +1 -0
- package/dist/runtime/host/stateful-authority-route-runtime.js +17 -9
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +2 -0
- package/dist/runtime/locations/in-memory-authority-store.js +22 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-location-store.js +3 -0
- package/dist/runtime/locations/internal-store-contracts.d.ts +1 -1
- package/dist/runtime/locations/location-store-repository.d.ts +1 -0
- package/dist/runtime/locations/location-store-repository.js +92 -49
- package/dist/runtime/spots/spot-serial-executor.js +4 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +5 -0
- package/dist/runtime/streams/index.d.ts +0 -1
- package/dist/runtime/streams/index.js +4 -3
- package/dist/runtime/streams/protocol.js +0 -9
- package/dist/runtime/streams/session-context.d.ts +0 -4
- package/dist/runtime/streams/session-context.js +0 -26
- package/dist/runtime/streams/session-serial-executor.d.ts +0 -1
- package/dist/runtime/streams/session-serial-executor.js +0 -3
- package/dist/runtime/streams/stream-message-utils.d.ts +0 -1
- package/dist/runtime/streams/stream-message-utils.js +0 -20
- package/dist/runtime/streams/stream-session-runtime.d.ts +6 -3
- package/dist/runtime/streams/stream-session-runtime.js +40 -85
- package/package.json +3 -3
- package/src/contracts/Configuration/Builders.ts +2 -0
- package/src/contracts/Configuration/InternalDefaults.ts +4 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +13 -0
- package/src/contracts/Configuration/RegistrationNormalizers.ts +25 -0
- package/src/contracts/Configuration/RegistrationTypes.ts +3 -0
- package/src/runtime/actors/actor-mailbox.ts +7 -2
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +1 -7
- package/src/runtime/execution/serial-execution-queue.ts +117 -29
- package/src/runtime/foundation/operation-registry.ts +16 -9
- package/src/runtime/foundation/service-authority-payload-codec.ts +0 -46
- package/src/runtime/foundation/service-stateful-registry.ts +10 -5
- package/src/runtime/foundation/service-stateful-runtime.ts +103 -181
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -25
- package/src/runtime/foundation/service-topology-registry.ts +30 -20
- package/src/runtime/host/instance-activation-authority.ts +58 -125
- package/src/runtime/host/spot-address-transport.ts +1 -1
- package/src/runtime/host/stateful-authority-route-runtime.ts +22 -9
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +42 -8
- package/src/runtime/locations/in-memory-location-store.ts +8 -0
- package/src/runtime/locations/internal-store-contracts.ts +1 -0
- package/src/runtime/locations/location-store-repository.ts +123 -64
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/spot-serial-executor.ts +4 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -0
- package/src/runtime/streams/index.ts +3 -1
- package/src/runtime/streams/protocol.ts +0 -13
- package/src/runtime/streams/session-context.ts +0 -32
- package/src/runtime/streams/session-serial-executor.ts +0 -8
- package/src/runtime/streams/stream-message-utils.ts +1 -27
- package/src/runtime/streams/stream-session-runtime.ts +54 -97
- package/dist/runtime/streams/session-requests.d.ts +0 -25
- package/dist/runtime/streams/session-requests.js +0 -101
- package/src/runtime/streams/session-requests.ts +0 -110
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { UINT64_MAX } from '@zlink-systems/stream-wire';
|
|
2
|
-
import type { Message } from '../../contracts/Common/Message';
|
|
3
|
-
import { copyMessage } from './stream-message-utils';
|
|
4
|
-
|
|
5
|
-
export class ZLinkPendingSessionRequest {
|
|
6
|
-
private completed = false;
|
|
7
|
-
private readonly timeout: ReturnType<typeof setTimeout> | undefined;
|
|
8
|
-
private resolvePromise!: (message: Message) => void;
|
|
9
|
-
private rejectPromise!: (error: unknown) => void;
|
|
10
|
-
readonly promise: Promise<Message>;
|
|
11
|
-
|
|
12
|
-
constructor(
|
|
13
|
-
private readonly tracker: ZLinkSessionRequestTracker,
|
|
14
|
-
readonly requestSeq: bigint,
|
|
15
|
-
timeoutMs: number | undefined
|
|
16
|
-
) {
|
|
17
|
-
this.promise = new Promise<Message>((resolve, reject) => {
|
|
18
|
-
this.resolvePromise = resolve;
|
|
19
|
-
this.rejectPromise = reject;
|
|
20
|
-
});
|
|
21
|
-
if (timeoutMs !== undefined) {
|
|
22
|
-
this.timeout = setTimeout(() => this.cancel(), timeoutMs);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
complete(payload: Message): void {
|
|
27
|
-
if (this.completed) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.completed = true;
|
|
31
|
-
this.clearTimeout();
|
|
32
|
-
this.resolvePromise(copyMessage(payload));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
fail(error: unknown): void {
|
|
36
|
-
if (this.completed) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.completed = true;
|
|
40
|
-
this.clearTimeout();
|
|
41
|
-
this.rejectPromise(error);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
cancel(): void {
|
|
45
|
-
if (this.completed) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.completed = true;
|
|
49
|
-
this.clearTimeout();
|
|
50
|
-
this.tracker.remove(this.requestSeq);
|
|
51
|
-
this.rejectPromise(new Error('Client stream request timed out.'));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
dispose(): void {
|
|
55
|
-
this.clearTimeout();
|
|
56
|
-
this.tracker.remove(this.requestSeq);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private clearTimeout(): void {
|
|
60
|
-
if (this.timeout !== undefined) {
|
|
61
|
-
clearTimeout(this.timeout);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class ZLinkSessionRequestTracker {
|
|
67
|
-
private readonly pending = new Map<bigint, ZLinkPendingSessionRequest>();
|
|
68
|
-
private nextRequestSeq = 0n;
|
|
69
|
-
|
|
70
|
-
start(timeoutMs?: number): ZLinkPendingSessionRequest {
|
|
71
|
-
const requestSeq = this.next();
|
|
72
|
-
const pending = new ZLinkPendingSessionRequest(this, requestSeq, timeoutMs);
|
|
73
|
-
if (this.pending.has(requestSeq)) {
|
|
74
|
-
throw new Error('Duplicate stream request sequence.');
|
|
75
|
-
}
|
|
76
|
-
this.pending.set(requestSeq, pending);
|
|
77
|
-
return pending;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
complete(requestSeq: bigint, payload: Message): boolean {
|
|
81
|
-
const pending = this.pending.get(requestSeq);
|
|
82
|
-
if (pending === undefined) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
this.pending.delete(requestSeq);
|
|
86
|
-
pending.complete(payload);
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
fail(requestSeq: bigint, error: unknown): boolean {
|
|
91
|
-
const pending = this.pending.get(requestSeq);
|
|
92
|
-
if (pending === undefined) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
this.pending.delete(requestSeq);
|
|
96
|
-
pending.fail(error);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
remove(requestSeq: bigint): void {
|
|
101
|
-
this.pending.delete(requestSeq);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private next(): bigint {
|
|
105
|
-
do {
|
|
106
|
-
this.nextRequestSeq = (this.nextRequestSeq + 1n) & UINT64_MAX;
|
|
107
|
-
} while (this.nextRequestSeq === 0n);
|
|
108
|
-
return this.nextRequestSeq;
|
|
109
|
-
}
|
|
110
|
-
}
|