@zlink-systems/framework 0.29.1 → 0.30.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/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Configuration/Builders.d.ts +1 -2
- package/dist/contracts/Configuration/Configs.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
- package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
- package/dist/contracts/Configuration/index.d.ts +1 -1
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Spots/Contracts.d.ts +2 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +14 -12
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +15 -7
- package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
- package/dist/runtime/actors/actor-local-native-join.js +9 -12
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/index.d.ts +2 -1
- package/dist/runtime/actors/index.js +18 -6
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +1 -1
- package/dist/runtime/admission.js +15 -5
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +9 -9
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +45 -23
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +5 -2
- package/dist/runtime/application-jobs/application-job-queue-scope.js +41 -21
- package/dist/runtime/application-jobs/contracts.d.ts +15 -2
- package/dist/runtime/backend/contracts/index.d.ts +27 -27
- package/dist/runtime/backend/mesh-completion-table.d.ts +15 -5
- package/dist/runtime/backend/mesh-completion-table.js +160 -50
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +53 -36
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +33 -31
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +50 -25
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +22 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +133 -149
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +15 -10
- package/dist/runtime/backend/raw-binding-port.d.ts +10 -3
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +58 -21
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
- package/dist/runtime/channels/channel-dispatchers.js +27 -26
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +83 -8
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-receive-loops.js +3 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
- package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/channels/channel-transports.d.ts +18 -15
- package/dist/runtime/channels/channel-transports.js +48 -31
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
- package/dist/runtime/execution/serial-execution-queue.js +1 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +37 -6
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +473 -220
- package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
- package/dist/runtime/foundation/service-liveness-registry.js +57 -44
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
- package/dist/runtime/foundation/service-mailbox.js +2 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -7
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +16 -4
- package/dist/runtime/foundation/service-topology-registry.js +69 -30
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-packet-relay.js +7 -7
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +28 -9
- package/dist/runtime/host/application-job-queue.js +214 -50
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +4 -1
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +154 -126
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
- package/dist/runtime/host/instance-activation-authority.js +89 -25
- package/dist/runtime/host/remote-bound-session-relay.js +2 -18
- package/dist/runtime/host/route-mesh-runtime.js +1 -1
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +215 -243
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +28 -14
- package/dist/runtime/host/spot-runtime-options-factory.js +3 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/domain-store-contract.d.ts +2 -2
- package/dist/runtime/locations/in-memory-authority-store.d.ts +4 -2
- package/dist/runtime/locations/in-memory-authority-store.js +80 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
- package/dist/runtime/locations/in-memory-location-store.js +19 -3
- package/dist/runtime/locations/internal-location-contracts.d.ts +3 -0
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/location-store-repository.d.ts +3 -2
- package/dist/runtime/locations/location-store-repository.js +165 -22
- package/dist/runtime/locations/resolvers.d.ts +2 -1
- package/dist/runtime/locations/resolvers.js +10 -1
- package/dist/runtime/locations/runtime.d.ts +1 -1
- package/dist/runtime/locations/runtime.js +24 -23
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +54 -0
- package/dist/runtime/messaging/submission-result.d.ts +2 -1
- package/dist/runtime/messaging/submission-result.js +7 -4
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +9 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +7 -3
- package/dist/runtime/spots/index.js +23 -16
- package/dist/runtime/spots/spot-activation.d.ts +3 -1
- package/dist/runtime/spots/spot-activation.js +21 -12
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
- package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
- package/dist/runtime/spots/spot-entry-activation.js +9 -3
- package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
- package/dist/runtime/spots/spot-handler-registry.js +18 -8
- package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +2 -1
- package/dist/runtime/spots/spot-node-runtime-manager.js +4 -11
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +24 -15
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -1
- package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
- package/dist/runtime/spots/spot-timer.js +1 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -28
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Configuration/Builders.ts +1 -2
- package/src/contracts/Configuration/Configs.ts +0 -6
- package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
- package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
- package/src/contracts/Configuration/index.ts +1 -6
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/internal.ts +1 -0
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +22 -8
- package/src/runtime/actors/actor-join-relocation.ts +1 -0
- package/src/runtime/actors/actor-local-native-join.ts +17 -26
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/index.ts +19 -5
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +18 -5
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +53 -27
- package/src/runtime/application-jobs/application-job-queue-scope.ts +56 -22
- package/src/runtime/application-jobs/contracts.ts +28 -2
- package/src/runtime/backend/contracts/index.ts +63 -32
- package/src/runtime/backend/mesh-completion-table.ts +175 -59
- package/src/runtime/backend/mesh-dispatch-pump.ts +59 -32
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -31
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +73 -37
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +209 -176
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +32 -13
- package/src/runtime/backend/raw-binding-port.ts +18 -3
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +90 -41
- package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +29 -27
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +133 -8
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-receive-loops.ts +3 -3
- package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
- package/src/runtime/channels/channel-runtime-manager.ts +29 -12
- package/src/runtime/channels/channel-socket-registry.ts +84 -130
- package/src/runtime/channels/channel-transports.ts +128 -60
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/message-flow.ts +1 -1
- package/src/runtime/execution/serial-execution-queue.ts +2 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +642 -253
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +128 -160
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -84
- package/src/runtime/foundation/service-topology-registry.ts +103 -42
- package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-runtime-options-factory.ts +14 -2
- package/src/runtime/host/application-job-queue.ts +249 -48
- package/src/runtime/host/entry-actor-runtime.ts +5 -0
- package/src/runtime/host/index.ts +224 -160
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/remote-bound-session-relay.ts +2 -23
- package/src/runtime/host/route-mesh-runtime.ts +1 -1
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +317 -291
- package/src/runtime/host/spot-address-transport.ts +49 -24
- package/src/runtime/host/spot-runtime-options-factory.ts +4 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/domain-store-contract.ts +6 -2
- package/src/runtime/locations/in-memory-authority-store.ts +113 -9
- package/src/runtime/locations/in-memory-location-store.ts +25 -3
- package/src/runtime/locations/internal-location-contracts.ts +4 -0
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +220 -15
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/locations/runtime.ts +28 -24
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/request-result.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +7 -3
- package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +45 -23
- package/src/runtime/spots/index.ts +30 -2
- package/src/runtime/spots/spot-activation.ts +33 -10
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
- package/src/runtime/spots/spot-entry-activation.ts +12 -2
- package/src/runtime/spots/spot-handler-registry.ts +41 -8
- package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
- package/src/runtime/spots/spot-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +3 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
- package/src/runtime/spots/spot-timer.ts +5 -1
- package/src/runtime/streams/stream-session-runtime.ts +13 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UINT64_MAX } from '@zlink-systems/stream-wire';
|
|
2
2
|
export interface ServiceProbe {
|
|
3
3
|
readonly nodeRoutingId: string;
|
|
4
|
-
readonly connectionId: string;
|
|
4
|
+
readonly connectionId: string | bigint;
|
|
5
5
|
readonly probeId: bigint;
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -10,20 +10,52 @@ export interface ServiceLivenessTick {
|
|
|
10
10
|
readonly timedOutNodes: readonly string[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export const DEFAULT_SERVICE_PROBE_INTERVAL_MS = 5_000;
|
|
14
|
+
export const DEFAULT_SERVICE_PEER_TIMEOUT_MS = 15_000;
|
|
15
|
+
|
|
16
|
+
export class ServiceLivenessConnection {
|
|
15
17
|
deadlineMs: number;
|
|
16
18
|
nextProbeMs: number;
|
|
17
19
|
outstandingProbe?: bigint;
|
|
18
|
-
ready: boolean;
|
|
19
|
-
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
constructor(
|
|
22
|
+
readonly connectionId: string | bigint,
|
|
23
|
+
nowMs: number,
|
|
24
|
+
private readonly probeIntervalMs = DEFAULT_SERVICE_PROBE_INTERVAL_MS,
|
|
25
|
+
private readonly peerTimeoutMs = DEFAULT_SERVICE_PEER_TIMEOUT_MS
|
|
26
|
+
) {
|
|
27
|
+
this.deadlineMs = nowMs + peerTimeoutMs;
|
|
28
|
+
this.nextProbeMs = nowMs;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
readonly recordReceived = (nowMs = performance.now()): void => {
|
|
32
|
+
this.deadlineMs = Math.max(this.deadlineMs, nowMs + this.peerTimeoutMs);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
isExpired(nowMs: number): boolean {
|
|
36
|
+
return nowMs >= this.deadlineMs;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
tryGetProbe(nowMs: number, allocateProbeId: () => bigint): bigint | undefined {
|
|
40
|
+
if (nowMs < this.nextProbeMs) return undefined;
|
|
41
|
+
this.outstandingProbe ??= allocateProbeId();
|
|
42
|
+
do {
|
|
43
|
+
this.nextProbeMs += this.probeIntervalMs;
|
|
44
|
+
} while (this.nextProbeMs <= nowMs);
|
|
45
|
+
return this.outstandingProbe;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
acknowledge(probeId: bigint, nowMs: number): boolean {
|
|
49
|
+
this.recordReceived(nowMs);
|
|
50
|
+
if (this.outstandingProbe !== probeId) return false;
|
|
51
|
+
this.outstandingProbe = undefined;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
23
55
|
|
|
24
56
|
/** Uses monotonic milliseconds and never treats application traffic as a probe ACK. */
|
|
25
57
|
export class ServiceLivenessRegistry {
|
|
26
|
-
private readonly peers = new Map<string,
|
|
58
|
+
private readonly peers = new Map<string, ServiceLivenessConnection>();
|
|
27
59
|
private nextProbeId = 1n;
|
|
28
60
|
|
|
29
61
|
constructor(
|
|
@@ -40,33 +72,31 @@ export class ServiceLivenessRegistry {
|
|
|
40
72
|
}
|
|
41
73
|
}
|
|
42
74
|
|
|
43
|
-
admit(
|
|
75
|
+
admit(
|
|
76
|
+
nodeRoutingId: string,
|
|
77
|
+
connectionId: string | bigint,
|
|
78
|
+
nowMs: number
|
|
79
|
+
): ServiceLivenessConnection {
|
|
44
80
|
requireIdentity(nodeRoutingId, 'nodeRoutingId');
|
|
45
|
-
requireIdentity(connectionId, 'connectionId');
|
|
81
|
+
if (typeof connectionId === 'string') requireIdentity(connectionId, 'connectionId');
|
|
82
|
+
else if (connectionId === 0n) throw new TypeError('connectionId must be nonzero.');
|
|
46
83
|
const current = this.peers.get(nodeRoutingId);
|
|
47
|
-
if (current?.connectionId === connectionId) return;
|
|
48
|
-
|
|
84
|
+
if (current?.connectionId === connectionId) return current;
|
|
85
|
+
const admitted = new ServiceLivenessConnection(
|
|
49
86
|
connectionId,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
87
|
+
nowMs,
|
|
88
|
+
this.probeIntervalMs,
|
|
89
|
+
this.peerTimeoutMs
|
|
90
|
+
);
|
|
91
|
+
this.peers.set(nodeRoutingId, admitted);
|
|
92
|
+
return admitted;
|
|
54
93
|
}
|
|
55
94
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
current === undefined ||
|
|
60
|
-
current.connectionId !== connectionId ||
|
|
61
|
-
current.ready ||
|
|
62
|
-
current.outstandingProbe !== undefined
|
|
63
|
-
)
|
|
64
|
-
return false;
|
|
65
|
-
current.nextProbeMs = Math.min(current.nextProbeMs, nowMs);
|
|
66
|
-
return true;
|
|
95
|
+
recordReceived(connection: ServiceLivenessConnection, nowMs: number): void {
|
|
96
|
+
connection.recordReceived(nowMs);
|
|
67
97
|
}
|
|
68
98
|
|
|
69
|
-
disconnect(nodeRoutingId: string, connectionId: string): boolean {
|
|
99
|
+
disconnect(nodeRoutingId: string, connectionId: string | bigint): boolean {
|
|
70
100
|
const current = this.peers.get(nodeRoutingId);
|
|
71
101
|
if (current === undefined || current.connectionId !== connectionId) return false;
|
|
72
102
|
this.peers.delete(nodeRoutingId);
|
|
@@ -75,27 +105,18 @@ export class ServiceLivenessRegistry {
|
|
|
75
105
|
|
|
76
106
|
acknowledge(
|
|
77
107
|
nodeRoutingId: string,
|
|
78
|
-
connectionId: string,
|
|
108
|
+
connectionId: string | bigint,
|
|
79
109
|
probeId: bigint,
|
|
80
110
|
nowMs: number
|
|
81
111
|
): boolean {
|
|
82
112
|
const current = this.peers.get(nodeRoutingId);
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
current.connectionId !== connectionId ||
|
|
86
|
-
current.outstandingProbe !== probeId
|
|
87
|
-
) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
current.outstandingProbe = undefined;
|
|
91
|
-
current.deadlineMs = nowMs + this.peerTimeoutMs;
|
|
92
|
-
current.ready = true;
|
|
93
|
-
return true;
|
|
113
|
+
if (current === undefined || current.connectionId !== connectionId) return false;
|
|
114
|
+
return current.acknowledge(probeId, nowMs);
|
|
94
115
|
}
|
|
95
116
|
|
|
96
117
|
acknowledgeProbe(
|
|
97
118
|
nodeRoutingId: string,
|
|
98
|
-
connectionId: string,
|
|
119
|
+
connectionId: string | bigint,
|
|
99
120
|
probeId: bigint
|
|
100
121
|
): ServiceProbe | undefined {
|
|
101
122
|
const current = this.peers.get(nodeRoutingId);
|
|
@@ -109,21 +130,14 @@ export class ServiceLivenessRegistry {
|
|
|
109
130
|
const probes: ServiceProbe[] = [];
|
|
110
131
|
const timedOutNodes: string[] = [];
|
|
111
132
|
for (const [nodeRoutingId, peer] of this.peers) {
|
|
112
|
-
if (peer.
|
|
133
|
+
if (peer.isExpired(nowMs)) {
|
|
113
134
|
timedOutNodes.push(nodeRoutingId);
|
|
114
135
|
this.peers.delete(nodeRoutingId);
|
|
115
136
|
continue;
|
|
116
137
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
nodeRoutingId,
|
|
121
|
-
connectionId: peer.connectionId,
|
|
122
|
-
probeId: peer.outstandingProbe
|
|
123
|
-
});
|
|
124
|
-
do {
|
|
125
|
-
peer.nextProbeMs += this.probeIntervalMs;
|
|
126
|
-
} while (peer.nextProbeMs <= nowMs);
|
|
138
|
+
const probeId = peer.tryGetProbe(nowMs, this.allocateProbeId);
|
|
139
|
+
if (probeId !== undefined)
|
|
140
|
+
probes.push({ nodeRoutingId, connectionId: peer.connectionId, probeId });
|
|
127
141
|
}
|
|
128
142
|
timedOutNodes.sort();
|
|
129
143
|
return { probes, timedOutNodes };
|
|
@@ -133,16 +147,11 @@ export class ServiceLivenessRegistry {
|
|
|
133
147
|
return this.peers.size;
|
|
134
148
|
}
|
|
135
149
|
|
|
136
|
-
|
|
137
|
-
const current = this.peers.get(nodeRoutingId);
|
|
138
|
-
return current?.connectionId === connectionId && current.ready;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private allocateProbeId(): bigint {
|
|
150
|
+
private readonly allocateProbeId = (): bigint => {
|
|
142
151
|
const result = this.nextProbeId++;
|
|
143
152
|
if (this.nextProbeId > UINT64_MAX) this.nextProbeId = 1n;
|
|
144
153
|
return result;
|
|
145
|
-
}
|
|
154
|
+
};
|
|
146
155
|
}
|
|
147
156
|
|
|
148
157
|
function requireIdentity(value: string, field: string): void {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApplicationJobRecordLease } from '../application-jobs/application-ingress-record-owner';
|
|
2
|
+
import type { ReceiveRecord } from './service-runtime-contracts';
|
|
2
3
|
|
|
3
4
|
export type ServiceMailboxDomain = 'application' | 'infrastructure';
|
|
4
5
|
|
|
@@ -23,6 +24,8 @@ export interface ServiceMailboxRecord {
|
|
|
23
24
|
readonly stateful?: unknown;
|
|
24
25
|
/** Host queue permit plus its ordinary Framework-owned ingress record. */
|
|
25
26
|
readonly applicationJob?: ApplicationJobRecordLease;
|
|
27
|
+
/** Unregistered raw-pull terminal, retained by the existing mailbox owner. */
|
|
28
|
+
readonly completion?: ReceiveRecord;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export interface ServiceMailboxClaim {
|
|
@@ -85,7 +88,10 @@ export class ServiceMailbox {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
tryEnqueue(record: ServiceMailboxRecord): boolean {
|
|
88
|
-
if (
|
|
91
|
+
if (
|
|
92
|
+
record.owner.length === 0 ||
|
|
93
|
+
(record.parts.length === 0 && record.completion === undefined)
|
|
94
|
+
) {
|
|
89
95
|
throw new TypeError('Mailbox records require an owner and retained payload.');
|
|
90
96
|
}
|
|
91
97
|
const target = this.domain(record.domain);
|
|
@@ -17,6 +17,7 @@ const DEFAULT_RELOCATION_CALLBACK_CONCURRENCY = 8;
|
|
|
17
17
|
|
|
18
18
|
export interface ServiceRelocationSealedWork {
|
|
19
19
|
readonly boundSessionState: Uint8Array;
|
|
20
|
+
readonly sessionBinding?: ServiceRelocationParticipant['sessionBinding'];
|
|
20
21
|
readonly queuedMessages: readonly ServiceRelocationQueuedMessage[];
|
|
21
22
|
readonly timers: readonly ServiceRelocationTimer[];
|
|
22
23
|
}
|
|
@@ -185,6 +186,7 @@ export class ServiceRelocationObjectCaptureOwner {
|
|
|
185
186
|
authorityOwnerGeneration: unit.authorityOwnerGeneration,
|
|
186
187
|
applicationState: Buffer.from(await unit.captureApplicationState(signal)),
|
|
187
188
|
boundSessionState: Buffer.from(work.boundSessionState),
|
|
189
|
+
...(work.sessionBinding === undefined ? {} : { sessionBinding: work.sessionBinding }),
|
|
188
190
|
queuedMessages: work.queuedMessages.map((message) => ({
|
|
189
191
|
sequence: message.sequence,
|
|
190
192
|
payload: Buffer.from(message.payload)
|
|
@@ -39,6 +39,7 @@ export interface ServiceRelocationParticipant {
|
|
|
39
39
|
readonly applicationStatePresent?: boolean;
|
|
40
40
|
readonly applicationState: Uint8Array;
|
|
41
41
|
readonly boundSessionState: Uint8Array;
|
|
42
|
+
readonly sessionBinding?: GeneratedRelocationEnvelopeV1['sessionBindings'][number];
|
|
42
43
|
readonly queuedMessages: readonly ServiceRelocationQueuedMessage[];
|
|
43
44
|
readonly timers: readonly ServiceRelocationTimer[];
|
|
44
45
|
}
|
|
@@ -726,6 +727,11 @@ export function encodeServiceRelocationEnvelope(
|
|
|
726
727
|
'timer due time'
|
|
727
728
|
)
|
|
728
729
|
})),
|
|
730
|
+
sessionBindings: participants.flatMap((participant, index) =>
|
|
731
|
+
participant.sessionBinding === undefined
|
|
732
|
+
? []
|
|
733
|
+
: [{ ...participant.sessionBinding, participantId: BigInt(index + 1) }]
|
|
734
|
+
),
|
|
729
735
|
pendingTimerTicks: pending.map((value) => ({
|
|
730
736
|
participantId: value.participantId,
|
|
731
737
|
order: value.order,
|
|
@@ -765,11 +771,22 @@ export function decodeServiceRelocationEnvelope(
|
|
|
765
771
|
const aggregateId = uuid(generated.relocationHigh, generated.relocationLow);
|
|
766
772
|
if (aggregateId === undefined) throw new TypeError('Invalid relocation identity.');
|
|
767
773
|
positiveBigInt(aggregateGeneration, 'aggregate generation');
|
|
774
|
+
const bindings = new Map(
|
|
775
|
+
generated.sessionBindings.map((binding) => [binding.participantId, binding])
|
|
776
|
+
);
|
|
777
|
+
for (const id of bindings.keys()) {
|
|
778
|
+
if (id > BigInt(generated.applicationStates.length))
|
|
779
|
+
throw new TypeError('Session binding participant is outside its inventory.');
|
|
780
|
+
}
|
|
768
781
|
const participants = generated.applicationStates.map((state, index) => {
|
|
769
782
|
if (state.participantId !== BigInt(index + 1)) {
|
|
770
783
|
throw new TypeError('Application state participant order is invalid.');
|
|
771
784
|
}
|
|
772
|
-
|
|
785
|
+
const binding = bindings.get(state.participantId);
|
|
786
|
+
return {
|
|
787
|
+
...wireParticipant(state.participantId, state.hasState, Buffer.from(state.payload)),
|
|
788
|
+
...(binding === undefined ? {} : { sessionBinding: binding })
|
|
789
|
+
};
|
|
773
790
|
});
|
|
774
791
|
const byId = new Map(participants.map((value) => [value.participantId!, value]));
|
|
775
792
|
for (const work of generated.savedWork) {
|
|
@@ -422,7 +422,12 @@ export interface ServiceSpot {
|
|
|
422
422
|
requestToChannel(
|
|
423
423
|
channelName: string,
|
|
424
424
|
parts: MessageLike | readonly MessageLike[],
|
|
425
|
-
options?: {
|
|
425
|
+
options?: {
|
|
426
|
+
flags?: number;
|
|
427
|
+
timeoutMs?: number;
|
|
428
|
+
applicationMetadata?: Buffer;
|
|
429
|
+
onAdmitted?: () => void;
|
|
430
|
+
}
|
|
426
431
|
): MeshOperationId;
|
|
427
432
|
sendToSpot(
|
|
428
433
|
targetNodeRid: unknown,
|
|
@@ -445,6 +450,7 @@ export interface ServiceSpot {
|
|
|
445
450
|
timeoutMs?: number;
|
|
446
451
|
applicationMetadata?: Buffer;
|
|
447
452
|
routeFence?: ServiceDirectSpotRouteFence;
|
|
453
|
+
onAdmitted?: () => void;
|
|
448
454
|
entrySpot?: boolean;
|
|
449
455
|
}
|
|
450
456
|
): MeshOperationId;
|