@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.
Files changed (87) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Configuration/Builders.d.ts +2 -0
  3. package/dist/contracts/Configuration/InternalDefaults.d.ts +3 -0
  4. package/dist/contracts/Configuration/InternalDefaults.js +4 -1
  5. package/dist/contracts/Configuration/RegistrationBuilders.js +9 -0
  6. package/dist/contracts/Configuration/RegistrationNormalizers.d.ts +1 -0
  7. package/dist/contracts/Configuration/RegistrationNormalizers.js +16 -0
  8. package/dist/contracts/Configuration/RegistrationTypes.d.ts +3 -0
  9. package/dist/runtime/actors/actor-mailbox.d.ts +2 -2
  10. package/dist/runtime/actors/actor-mailbox.js +2 -2
  11. package/dist/runtime/backend/node/node-raw-mesh-backend.js +1 -3
  12. package/dist/runtime/execution/serial-execution-queue.d.ts +12 -3
  13. package/dist/runtime/execution/serial-execution-queue.js +116 -28
  14. package/dist/runtime/foundation/operation-registry.d.ts +3 -2
  15. package/dist/runtime/foundation/operation-registry.js +5 -1
  16. package/dist/runtime/foundation/service-authority-payload-codec.d.ts +0 -2
  17. package/dist/runtime/foundation/service-authority-payload-codec.js +0 -43
  18. package/dist/runtime/foundation/service-stateful-registry.d.ts +4 -3
  19. package/dist/runtime/foundation/service-stateful-registry.js +5 -2
  20. package/dist/runtime/foundation/service-stateful-runtime.d.ts +1 -8
  21. package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
  22. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -11
  23. package/dist/runtime/foundation/service-stateful-wire-codec.js +1 -23
  24. package/dist/runtime/foundation/service-topology-registry.d.ts +5 -0
  25. package/dist/runtime/foundation/service-topology-registry.js +16 -17
  26. package/dist/runtime/host/instance-activation-authority.d.ts +0 -1
  27. package/dist/runtime/host/instance-activation-authority.js +46 -97
  28. package/dist/runtime/host/spot-address-transport.js +1 -1
  29. package/dist/runtime/host/stateful-authority-route-runtime.d.ts +1 -0
  30. package/dist/runtime/host/stateful-authority-route-runtime.js +17 -9
  31. package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
  32. package/dist/runtime/locations/in-memory-authority-store.d.ts +2 -0
  33. package/dist/runtime/locations/in-memory-authority-store.js +22 -8
  34. package/dist/runtime/locations/in-memory-location-store.d.ts +1 -0
  35. package/dist/runtime/locations/in-memory-location-store.js +3 -0
  36. package/dist/runtime/locations/internal-store-contracts.d.ts +1 -1
  37. package/dist/runtime/locations/location-store-repository.d.ts +1 -0
  38. package/dist/runtime/locations/location-store-repository.js +92 -49
  39. package/dist/runtime/spots/spot-serial-executor.js +4 -1
  40. package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
  41. package/dist/runtime/spots/spot-serial-turn-executor.js +5 -0
  42. package/dist/runtime/streams/index.d.ts +0 -1
  43. package/dist/runtime/streams/index.js +4 -3
  44. package/dist/runtime/streams/protocol.js +0 -9
  45. package/dist/runtime/streams/session-context.d.ts +0 -4
  46. package/dist/runtime/streams/session-context.js +0 -26
  47. package/dist/runtime/streams/session-serial-executor.d.ts +0 -1
  48. package/dist/runtime/streams/session-serial-executor.js +0 -3
  49. package/dist/runtime/streams/stream-message-utils.d.ts +0 -1
  50. package/dist/runtime/streams/stream-message-utils.js +0 -20
  51. package/dist/runtime/streams/stream-session-runtime.d.ts +6 -3
  52. package/dist/runtime/streams/stream-session-runtime.js +40 -85
  53. package/package.json +3 -3
  54. package/src/contracts/Configuration/Builders.ts +2 -0
  55. package/src/contracts/Configuration/InternalDefaults.ts +4 -0
  56. package/src/contracts/Configuration/RegistrationBuilders.ts +13 -0
  57. package/src/contracts/Configuration/RegistrationNormalizers.ts +25 -0
  58. package/src/contracts/Configuration/RegistrationTypes.ts +3 -0
  59. package/src/runtime/actors/actor-mailbox.ts +7 -2
  60. package/src/runtime/backend/node/node-raw-mesh-backend.ts +1 -7
  61. package/src/runtime/execution/serial-execution-queue.ts +117 -29
  62. package/src/runtime/foundation/operation-registry.ts +16 -9
  63. package/src/runtime/foundation/service-authority-payload-codec.ts +0 -46
  64. package/src/runtime/foundation/service-stateful-registry.ts +10 -5
  65. package/src/runtime/foundation/service-stateful-runtime.ts +103 -181
  66. package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -25
  67. package/src/runtime/foundation/service-topology-registry.ts +30 -20
  68. package/src/runtime/host/instance-activation-authority.ts +58 -125
  69. package/src/runtime/host/spot-address-transport.ts +1 -1
  70. package/src/runtime/host/stateful-authority-route-runtime.ts +22 -9
  71. package/src/runtime/locations/domain-store-contract.ts +5 -0
  72. package/src/runtime/locations/in-memory-authority-store.ts +42 -8
  73. package/src/runtime/locations/in-memory-location-store.ts +8 -0
  74. package/src/runtime/locations/internal-store-contracts.ts +1 -0
  75. package/src/runtime/locations/location-store-repository.ts +123 -64
  76. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
  77. package/src/runtime/spots/spot-serial-executor.ts +4 -1
  78. package/src/runtime/spots/spot-serial-turn-executor.ts +10 -0
  79. package/src/runtime/streams/index.ts +3 -1
  80. package/src/runtime/streams/protocol.ts +0 -13
  81. package/src/runtime/streams/session-context.ts +0 -32
  82. package/src/runtime/streams/session-serial-executor.ts +0 -8
  83. package/src/runtime/streams/stream-message-utils.ts +1 -27
  84. package/src/runtime/streams/stream-session-runtime.ts +54 -97
  85. package/dist/runtime/streams/session-requests.d.ts +0 -25
  86. package/dist/runtime/streams/session-requests.js +0 -101
  87. 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
- }