@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
|
@@ -41,6 +41,7 @@ import { putNewRelocationBlob, relocationBlobReference } from '../locations/relo
|
|
|
41
41
|
|
|
42
42
|
import {
|
|
43
43
|
encodeInstanceActivationRecoveryEnvelope,
|
|
44
|
+
decodeInstanceActivationRecoveryEnvelope,
|
|
44
45
|
type ServiceInstanceActivationRecoveryEnvelope
|
|
45
46
|
} from '../foundation/service-instance-activation-recovery-codec';
|
|
46
47
|
|
|
@@ -57,6 +58,9 @@ interface PendingReservation {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export interface ZLinkInstanceActivationAuthorityOptions {
|
|
61
|
+
readonly relocationPolicy?: (
|
|
62
|
+
stableType: string
|
|
63
|
+
) => import('../locations/internal-location-contracts').ZLinkObjectReserveRequest['actorRelocationPolicy'];
|
|
60
64
|
readonly store: ZLinkObjectCreationStore & ZLinkAuthorityStore;
|
|
61
65
|
readonly relocationStore?: ZLinkRelocationStore;
|
|
62
66
|
readonly meshName: string;
|
|
@@ -73,9 +77,101 @@ export class ZLinkInstanceActivationAuthority implements ServiceAsyncInstanceAct
|
|
|
73
77
|
|
|
74
78
|
constructor(private readonly options: ZLinkInstanceActivationAuthorityOptions) {}
|
|
75
79
|
|
|
76
|
-
async read(
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
async read(
|
|
81
|
+
target: ServiceInstanceActivationTarget,
|
|
82
|
+
instanceIntent?: true,
|
|
83
|
+
activation?: ServiceInstanceActivationRecoveryEnvelope,
|
|
84
|
+
acceptsLocal?: (route: ServiceInstanceRouteFence) => boolean
|
|
85
|
+
): Promise<ServiceInstanceAuthorityRead> {
|
|
86
|
+
const key = authorityKey(target.targetSpotId);
|
|
87
|
+
const current = await this.options.store.readAuthority(key);
|
|
88
|
+
if (current.kind !== 'snapshot') return { kind: 'missing' };
|
|
89
|
+
const ready = decodeServiceInstanceAuthorityPayload(current.payload);
|
|
90
|
+
const resolved = readyRead(current, target, ready);
|
|
91
|
+
if (
|
|
92
|
+
ready?.state === 'ready' &&
|
|
93
|
+
resolved.kind === 'ready' &&
|
|
94
|
+
acceptsLocal?.(resolved.route) === true
|
|
95
|
+
) {
|
|
96
|
+
return resolved;
|
|
97
|
+
}
|
|
98
|
+
if (
|
|
99
|
+
activation !== undefined &&
|
|
100
|
+
current.allocation.objectKind === 'instance_spot' &&
|
|
101
|
+
routingIdsEqual(current.allocation.descriptor.rid, target.targetNodeRid) &&
|
|
102
|
+
current.allocation.descriptorLifecycleGeneration === target.targetNodeGeneration
|
|
103
|
+
) {
|
|
104
|
+
const reference =
|
|
105
|
+
current.pendingCreation?.requestContentReference ?? ready?.activationRecovery?.reference;
|
|
106
|
+
if (reference !== undefined) {
|
|
107
|
+
const root = await this.options.relocationStore?.read(relocationBlobReference(reference));
|
|
108
|
+
if (root?.kind !== 'found') {
|
|
109
|
+
throw new ZLinkFrameworkException(
|
|
110
|
+
ZLinkFrameworkErrorKind.DataLost,
|
|
111
|
+
'Stored Instance activation is missing.'
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
let stored: ServiceInstanceActivationRecoveryEnvelope;
|
|
115
|
+
try {
|
|
116
|
+
stored = decodeInstanceActivationRecoveryEnvelope(root.bytes);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (!(error instanceof TypeError || error instanceof RangeError)) throw error;
|
|
119
|
+
throw new ZLinkFrameworkException(
|
|
120
|
+
ZLinkFrameworkErrorKind.ProtocolError,
|
|
121
|
+
'Stored Instance activation is invalid.'
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (
|
|
125
|
+
stored.operation.high === activation.operation.high &&
|
|
126
|
+
stored.operation.low === activation.operation.low &&
|
|
127
|
+
(stored.targetMeshName !== activation.targetMeshName ||
|
|
128
|
+
stored.target.stableType !== target.stableType ||
|
|
129
|
+
stored.target.descriptorVersion !== target.descriptorVersion ||
|
|
130
|
+
stored.deadlineUnixMs !== activation.deadlineUnixMs ||
|
|
131
|
+
(stored.metadataFrame === undefined) !== (activation.metadataFrame === undefined) ||
|
|
132
|
+
(stored.metadataFrame !== undefined &&
|
|
133
|
+
activation.metadataFrame !== undefined &&
|
|
134
|
+
Buffer.compare(stored.metadataFrame, activation.metadataFrame) !== 0))
|
|
135
|
+
) {
|
|
136
|
+
throw new ZLinkFrameworkException(
|
|
137
|
+
ZLinkFrameworkErrorKind.ProtocolError,
|
|
138
|
+
'Instance route does not match the stored activation.'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (
|
|
145
|
+
instanceIntent === true &&
|
|
146
|
+
current.allocation.state === 'active' &&
|
|
147
|
+
ready?.state === 'ready'
|
|
148
|
+
) {
|
|
149
|
+
if (
|
|
150
|
+
current.allocation.objectKind !== 'instance_spot' ||
|
|
151
|
+
current.allocation.stableType !== target.stableType
|
|
152
|
+
) {
|
|
153
|
+
throw createInternalFrameworkException(
|
|
154
|
+
ZLinkFrameworkInternalErrorKind.SpotTypeMismatch,
|
|
155
|
+
'Instance activation type does not match the current authority.'
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
const released = await this.options.store.releaseEndedReservation?.(
|
|
159
|
+
key,
|
|
160
|
+
current.storeVersion.value,
|
|
161
|
+
undefined,
|
|
162
|
+
{
|
|
163
|
+
key: { kind: 'instance_spot', globalId: target.targetSpotId },
|
|
164
|
+
intent: { stableType: target.stableType },
|
|
165
|
+
actorRelocationPolicy: this.options.relocationPolicy?.(target.stableType)
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
if (released === true) return { kind: 'missing' };
|
|
169
|
+
const refreshed = await this.options.store.readAuthority(key);
|
|
170
|
+
return refreshed.kind === 'snapshot'
|
|
171
|
+
? readyRead(refreshed, target, decodeServiceInstanceAuthorityPayload(refreshed.payload))
|
|
172
|
+
: { kind: 'missing' };
|
|
173
|
+
}
|
|
174
|
+
return resolved;
|
|
79
175
|
}
|
|
80
176
|
|
|
81
177
|
async reserve(
|
|
@@ -117,6 +213,7 @@ export class ZLinkInstanceActivationAuthority implements ServiceAsyncInstanceAct
|
|
|
117
213
|
reserved = await this.options.store.reserve(
|
|
118
214
|
{
|
|
119
215
|
key: { kind: 'instance_spot', globalId: target.targetSpotId },
|
|
216
|
+
actorRelocationPolicy: this.options.relocationPolicy?.(target.stableType),
|
|
120
217
|
intent: {
|
|
121
218
|
stableType: target.stableType,
|
|
122
219
|
requestContentReference: stored.reference.value,
|
|
@@ -310,7 +407,11 @@ export class ZLinkInstanceActivationAuthority implements ServiceAsyncInstanceAct
|
|
|
310
407
|
}
|
|
311
408
|
const current = await this.options.store.readAuthority(authorityKey(target.targetSpotId));
|
|
312
409
|
if (current.kind === 'snapshot') {
|
|
313
|
-
const ready = readyRead(
|
|
410
|
+
const ready = readyRead(
|
|
411
|
+
current,
|
|
412
|
+
target,
|
|
413
|
+
decodeServiceInstanceAuthorityPayload(current.payload)
|
|
414
|
+
);
|
|
314
415
|
if (ready.kind === 'ready') {
|
|
315
416
|
this.pending.delete(reservation.token);
|
|
316
417
|
return { kind: 'lost', route: ready.route };
|
|
@@ -344,7 +445,7 @@ export class ZLinkInstanceActivationAuthority implements ServiceAsyncInstanceAct
|
|
|
344
445
|
throw new Error('Instance activation authority changed before inbox release.');
|
|
345
446
|
}
|
|
346
447
|
const recovery = decoded.activationRecovery;
|
|
347
|
-
if (recovery === undefined) return routeFromSnapshot(current);
|
|
448
|
+
if (recovery === undefined) return routeFromSnapshot(current, decoded.spotId);
|
|
348
449
|
let completed = current;
|
|
349
450
|
if (recovery.replayCursor < recovery.inboxSequence) {
|
|
350
451
|
const cursorStored = await this.options.store.compareExchangeAuthority(
|
|
@@ -459,22 +560,19 @@ export class ZLinkInstanceActivationAuthority implements ServiceAsyncInstanceAct
|
|
|
459
560
|
|
|
460
561
|
function readyRead(
|
|
461
562
|
snapshot: ZLinkAuthoritySnapshot,
|
|
462
|
-
target: ServiceInstanceActivationTarget
|
|
563
|
+
target: ServiceInstanceActivationTarget,
|
|
564
|
+
decoded: ReturnType<typeof decodeServiceInstanceAuthorityPayload>
|
|
463
565
|
): ServiceInstanceAuthorityRead {
|
|
464
|
-
const decoded =
|
|
465
|
-
decodeServiceReadySpotAuthority(snapshot.payload) ??
|
|
466
|
-
decodeServiceClosingSpotAuthority(snapshot.payload);
|
|
467
|
-
const creating = decodeServiceInstanceAuthorityPayload(snapshot.payload);
|
|
468
566
|
if (
|
|
469
|
-
|
|
567
|
+
decoded?.state === 'coldActivating' &&
|
|
470
568
|
snapshot.allocation.objectKind === 'instance_spot' &&
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
routingIdsEqual(
|
|
569
|
+
decoded.stableType === target.stableType &&
|
|
570
|
+
decoded.spotId === target.targetSpotId &&
|
|
571
|
+
decoded.ownerId === snapshot.ownerId &&
|
|
572
|
+
decoded.ownerLeaseGeneration === snapshot.ownerLeaseGeneration &&
|
|
573
|
+
decoded.ownerMeshName === snapshot.allocation.descriptor.meshName &&
|
|
574
|
+
decoded.ownerNodeGeneration === snapshot.allocation.descriptorLifecycleGeneration &&
|
|
575
|
+
routingIdsEqual(decoded.ownerNodeRid, snapshot.allocation.descriptor.rid) &&
|
|
478
576
|
routingIdsEqual(target.targetNodeRid, snapshot.allocation.descriptor.rid) &&
|
|
479
577
|
target.targetNodeGeneration === snapshot.allocation.descriptorLifecycleGeneration
|
|
480
578
|
) {
|
|
@@ -486,7 +584,8 @@ function readyRead(
|
|
|
486
584
|
};
|
|
487
585
|
}
|
|
488
586
|
if (
|
|
489
|
-
decoded
|
|
587
|
+
decoded === undefined ||
|
|
588
|
+
decoded.state === 'coldActivating' ||
|
|
490
589
|
decoded.stableType !== target.stableType ||
|
|
491
590
|
decoded.spotId !== target.targetSpotId ||
|
|
492
591
|
snapshot.allocation.objectKind !== 'instance_spot' ||
|
|
@@ -501,7 +600,7 @@ function readyRead(
|
|
|
501
600
|
) {
|
|
502
601
|
return { kind: 'missing' };
|
|
503
602
|
}
|
|
504
|
-
return { kind: 'ready', route: routeFromSnapshot(snapshot), authority: snapshot };
|
|
603
|
+
return { kind: 'ready', route: routeFromSnapshot(snapshot, decoded.spotId), authority: snapshot };
|
|
505
604
|
}
|
|
506
605
|
|
|
507
606
|
function requireCommitIdentity(
|
|
@@ -529,17 +628,23 @@ function requireCommitIdentity(
|
|
|
529
628
|
}
|
|
530
629
|
}
|
|
531
630
|
|
|
532
|
-
function routeFromSnapshot(
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (
|
|
537
|
-
|
|
631
|
+
function routeFromSnapshot(
|
|
632
|
+
snapshot: ZLinkAuthoritySnapshot,
|
|
633
|
+
spotId?: string
|
|
634
|
+
): ServiceInstanceRouteFence {
|
|
635
|
+
if (spotId === undefined) {
|
|
636
|
+
const decoded =
|
|
637
|
+
decodeServiceReadySpotAuthority(snapshot.payload) ??
|
|
638
|
+
decodeServiceClosingSpotAuthority(snapshot.payload);
|
|
639
|
+
if (decoded?.kind !== 'instance_spot') {
|
|
640
|
+
throw new Error('Instance authority is not Ready.');
|
|
641
|
+
}
|
|
642
|
+
spotId = decoded.spotId;
|
|
538
643
|
}
|
|
539
644
|
return {
|
|
540
645
|
targetNodeRid: String(snapshot.allocation.descriptor.rid),
|
|
541
646
|
targetNodeGeneration: snapshot.allocation.descriptorLifecycleGeneration,
|
|
542
|
-
targetSpotId:
|
|
647
|
+
targetSpotId: spotId,
|
|
543
648
|
objectGeneration: snapshot.objectGeneration,
|
|
544
649
|
ownerId: snapshot.ownerId,
|
|
545
650
|
authorityOwnerGeneration: snapshot.authorityOwnerGeneration,
|
|
@@ -845,24 +845,16 @@ function validateSessionRelocationRouteAgainstSeal(
|
|
|
845
845
|
route: ServiceSessionRelocationRoute,
|
|
846
846
|
sealed: ServiceSessionRelocationSealed
|
|
847
847
|
): void {
|
|
848
|
-
const sameCoordinator =
|
|
849
|
-
route.coordinator.ownerId === sealed.coordinator.ownerId &&
|
|
850
|
-
route.coordinator.leaseGeneration === sealed.coordinator.leaseGeneration &&
|
|
851
|
-
route.coordinator.nodeRid === sealed.coordinator.nodeRid &&
|
|
852
|
-
route.coordinator.nodeGeneration === sealed.coordinator.nodeGeneration &&
|
|
853
|
-
route.coordinator.expectedAuthorityStoreVersion ===
|
|
854
|
-
sealed.coordinator.expectedAuthorityStoreVersion;
|
|
855
848
|
const sameSession =
|
|
856
|
-
route.session.sessionOwnerNodeRid
|
|
849
|
+
routingIdsEqual(route.session.sessionOwnerNodeRid, sealed.session.sessionOwnerNodeRid) &&
|
|
857
850
|
route.session.sessionOwnerNodeGeneration === sealed.session.sessionOwnerNodeGeneration &&
|
|
858
851
|
route.session.sessionOwnerId === sealed.session.sessionOwnerId &&
|
|
859
852
|
route.session.sessionOwnerLeaseGeneration === sealed.session.sessionOwnerLeaseGeneration &&
|
|
860
|
-
route.session.sessionRid
|
|
853
|
+
routingIdsEqual(route.session.sessionRid, sealed.session.sessionRid) &&
|
|
861
854
|
route.session.bindingGeneration === sealed.session.bindingGeneration;
|
|
862
855
|
if (
|
|
863
856
|
route.relocation.high !== sealed.relocation.high ||
|
|
864
857
|
route.relocation.low !== sealed.relocation.low ||
|
|
865
|
-
!sameCoordinator ||
|
|
866
858
|
!sameSession ||
|
|
867
859
|
route.actor.actorId !== sealed.actor.actor.actorId ||
|
|
868
860
|
route.actor.generation !== sealed.actor.actor.generation
|
|
@@ -871,17 +863,4 @@ function validateSessionRelocationRouteAgainstSeal(
|
|
|
871
863
|
`Session relocation '${serviceWireBarrierKey(route)}' changed its command 42 fence.`
|
|
872
864
|
);
|
|
873
865
|
}
|
|
874
|
-
if (route.route.action === 'commit') {
|
|
875
|
-
if (route.route.previousAuthorityOwnerGeneration !== sealed.actor.authorityOwnerGeneration) {
|
|
876
|
-
throw new ServiceWireProtocolError(
|
|
877
|
-
`Session relocation '${serviceWireBarrierKey(route)}' changed its source authority fence.`
|
|
878
|
-
);
|
|
879
|
-
}
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
if (route.route.currentAuthorityOwnerGeneration !== sealed.actor.authorityOwnerGeneration) {
|
|
883
|
-
throw new ServiceWireProtocolError(
|
|
884
|
-
`Session relocation '${serviceWireBarrierKey(route)}' abort changed its authority fence.`
|
|
885
|
-
);
|
|
886
|
-
}
|
|
887
866
|
}
|
|
@@ -588,7 +588,7 @@ export class ZLinkRouteMeshRuntimeCoordinator implements ZLinkRouteMeshRuntime {
|
|
|
588
588
|
this.options.forceStopResources(meshName).catch(() => undefined)
|
|
589
589
|
)
|
|
590
590
|
);
|
|
591
|
-
result = { kind: 'forceStopped', reason };
|
|
591
|
+
result = { kind: 'forceStopped', reason, error };
|
|
592
592
|
for (const [meshName, state] of entries) {
|
|
593
593
|
this.transition(meshName, state, ZLinkTopologyState.Failed);
|
|
594
594
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SERVICE_WIRE_MAJOR_OFFSET,
|
|
3
|
+
SERVICE_WIRE_COMMAND_OFFSET,
|
|
3
4
|
SERVICE_WIRE_PREFIX_SIZE
|
|
4
5
|
} from '../foundation/service-wire-binary-primitives';
|
|
5
6
|
import {
|
|
@@ -27,14 +28,19 @@ export function decodeServiceRelocationControlRequest(
|
|
|
27
28
|
const bytes = Buffer.isBuffer(payload)
|
|
28
29
|
? payload
|
|
29
30
|
: Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
31
|
+
if (serviceRelocationControlCommand(bytes) === undefined) return undefined;
|
|
32
|
+
return decodeMaintenanceRelocationControl(bytes);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function serviceRelocationControlCommand(payload: Uint8Array): number | undefined {
|
|
30
36
|
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
payload.byteLength < SERVICE_WIRE_PREFIX_SIZE ||
|
|
38
|
+
payload[0] !== SERVICE_WIRE_MAGIC[0] ||
|
|
39
|
+
payload[1] !== SERVICE_WIRE_MAGIC[1] ||
|
|
40
|
+
payload[SERVICE_WIRE_MAJOR_OFFSET] !== SERVICE_WIRE_MAJOR
|
|
35
41
|
)
|
|
36
42
|
return undefined;
|
|
37
|
-
return
|
|
43
|
+
return payload[SERVICE_WIRE_COMMAND_OFFSET];
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
export function encodeServiceRelocationControlResponse(
|