@zlink-systems/framework 0.24.0 → 0.26.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/Channels/IZLinkFanoutClient.d.ts +0 -6
- package/dist/contracts/RouteMesh/RuntimeTopology.d.ts +8 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +1 -0
- package/dist/runtime/activation-admission.d.ts +29 -0
- package/dist/runtime/activation-admission.js +61 -0
- package/dist/runtime/actors/actor-context.js +6 -6
- package/dist/runtime/actors/actor-handoff.d.ts +9 -3
- package/dist/runtime/actors/actor-handoff.js +28 -17
- package/dist/runtime/actors/actor-local-native-join.js +2 -18
- package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
- package/dist/runtime/actors/actor-remote-joiner.js +6 -8
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +4 -2
- package/dist/runtime/actors/actor-source-transfer.d.ts +5 -5
- package/dist/runtime/actors/deferred-join-completion.d.ts +14 -0
- package/dist/runtime/actors/deferred-join-completion.js +20 -0
- package/dist/runtime/actors/index.d.ts +1 -1
- package/dist/runtime/actors/index.js +15 -5
- package/dist/runtime/admission.d.ts +5 -1
- package/dist/runtime/admission.js +4 -0
- package/dist/runtime/backend/contracts/index.d.ts +2 -10
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -9
- package/dist/runtime/backend/node/node-backend-adapter-factory.d.ts +1 -2
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +4 -18
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +6 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +12 -28
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +1 -1
- package/dist/runtime/backend/node/node-event-loop-poller.js +8 -2
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +11 -3
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +12 -9
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +61 -29
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +1 -1
- package/dist/runtime/backend/raw-binding-port.d.ts +12 -0
- package/dist/runtime/channels/channel-clients.d.ts +0 -1
- package/dist/runtime/channels/channel-clients.js +0 -8
- package/dist/runtime/channels/channel-outbound-operations.js +2 -10
- package/dist/runtime/channels/channel-runtime-manager.d.ts +2 -5
- package/dist/runtime/channels/channel-runtime-manager.js +1 -12
- package/dist/runtime/channels/channel-socket-registry.d.ts +17 -4
- package/dist/runtime/channels/channel-socket-registry.js +49 -62
- package/dist/runtime/channels/channel-transports.d.ts +0 -3
- package/dist/runtime/channels/fanout-location-runtime.js +3 -9
- package/dist/runtime/execution/index.d.ts +18 -8
- package/dist/runtime/execution/index.js +55 -29
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -6
- package/dist/runtime/execution/serial-execution-queue.js +49 -15
- package/dist/runtime/foundation/listener-records.d.ts +11 -0
- package/dist/runtime/foundation/listener-records.js +20 -0
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +10 -21
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +66 -392
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +1 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +8 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +23 -2
- package/dist/runtime/foundation/service-relocation-coordinator.d.ts +9 -0
- package/dist/runtime/foundation/service-relocation-coordinator.js +14 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +8 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +16 -4
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +6 -13
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -7
- package/dist/runtime/foundation/service-stateful-runtime.js +100 -60
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +9 -4
- package/dist/runtime/foundation/service-stateful-wire-codec.js +153 -90
- package/dist/runtime/foundation/service-topology-registry.d.ts +1 -2
- package/dist/runtime/foundation/service-topology-registry.js +6 -30
- package/dist/runtime/host/actor-transfer-runtime.d.ts +17 -15
- package/dist/runtime/host/actor-transfer-runtime.js +73 -86
- package/dist/runtime/host/index.d.ts +6 -2
- package/dist/runtime/host/index.js +63 -37
- package/dist/runtime/host/remote-bound-session-relay.js +4 -3
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -0
- package/dist/runtime/host/route-mesh-runtime.js +7 -5
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +50 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +343 -270
- package/dist/runtime/host/spot-runtime-options-factory.d.ts +7 -4
- package/dist/runtime/host/spot-runtime-options-factory.js +4 -8
- package/dist/runtime/host/stateful-authority-route-runtime.js +6 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +11 -3
- package/dist/runtime/host/user-spot-creation-coordinator.js +85 -87
- package/dist/runtime/locations/in-memory-provider-location-store.js +8 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -1
- package/dist/runtime/locations/lifecycle.js +2 -2
- package/dist/runtime/locations/resolvers.js +7 -2
- package/dist/runtime/locations/spot-location-claims.d.ts +2 -2
- package/dist/runtime/locations/spot-location-claims.js +3 -27
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +5 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +3 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +3 -3
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +4 -4
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +3 -3
- package/dist/runtime/spots/index.d.ts +25 -19
- package/dist/runtime/spots/index.js +207 -205
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +34 -31
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -11
- package/dist/runtime/spots/spot-activation-state.js +4 -17
- package/dist/runtime/spots/spot-activation.d.ts +8 -6
- package/dist/runtime/spots/spot-activation.js +54 -49
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +1 -1
- package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-actor-join-dispatch.js +3 -5
- package/dist/runtime/spots/spot-actor-lifecycle-drain.js +2 -2
- package/dist/runtime/spots/spot-actor-membership.d.ts +4 -0
- package/dist/runtime/spots/spot-actor-membership.js +26 -12
- package/dist/runtime/spots/spot-entry-activation.d.ts +1 -2
- package/dist/runtime/spots/spot-entry-activation.js +0 -1
- package/dist/runtime/spots/spot-manager-public.js +1 -1
- package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +1 -1
- package/dist/runtime/spots/spot-native-actor-join-admission.js +2 -2
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +5 -5
- package/dist/runtime/spots/spot-node-runtime-manager.js +7 -11
- package/dist/runtime/spots/spot-outbound.js +1 -29
- package/dist/runtime/spots/spot-routed-actor-admission.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-actor-admission.js +10 -0
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +2 -6
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +2 -70
- package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -5
- package/dist/runtime/spots/spot-serial-executor.d.ts +5 -0
- package/dist/runtime/spots/spot-serial-executor.js +8 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +8 -4
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +13 -15
- package/dist/runtime/streams/actor-session-binding-registry.js +19 -171
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +3 -4
- package/dist/runtime/streams/bound-session-service.js +1 -18
- package/dist/runtime/streams/index.d.ts +2 -0
- package/dist/runtime/streams/index.js +19 -19
- package/dist/runtime/streams/session-serial-executor.js +2 -2
- package/package.json +3 -3
- package/src/contracts/Channels/IZLinkFanoutClient.ts +0 -7
- package/src/contracts/RouteMesh/RuntimeTopology.ts +10 -0
- package/src/internal.ts +1 -0
- package/src/runtime/activation-admission.ts +78 -0
- package/src/runtime/actors/actor-context.ts +6 -6
- package/src/runtime/actors/actor-handoff.ts +31 -23
- package/src/runtime/actors/actor-local-native-join.ts +3 -42
- package/src/runtime/actors/actor-remote-joiner.ts +6 -25
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -10
- package/src/runtime/actors/actor-source-transfer.ts +5 -18
- package/src/runtime/actors/deferred-join-completion.ts +40 -0
- package/src/runtime/actors/index.ts +22 -9
- package/src/runtime/admission.ts +5 -1
- package/src/runtime/backend/contracts/index.ts +2 -13
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -10
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +5 -25
- package/src/runtime/backend/node/node-backend-adapter-support.ts +9 -29
- package/src/runtime/backend/node/node-event-loop-poller.ts +14 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +17 -3
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +65 -32
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +2 -2
- package/src/runtime/backend/raw-binding-port.ts +13 -0
- package/src/runtime/channels/channel-clients.ts +0 -11
- package/src/runtime/channels/channel-outbound-operations.ts +3 -11
- package/src/runtime/channels/channel-runtime-manager.ts +4 -15
- package/src/runtime/channels/channel-socket-registry.ts +69 -71
- package/src/runtime/channels/channel-transports.ts +0 -3
- package/src/runtime/channels/fanout-location-runtime.ts +4 -16
- package/src/runtime/execution/index.ts +68 -30
- package/src/runtime/execution/serial-execution-queue.ts +52 -20
- package/src/runtime/foundation/listener-records.ts +21 -0
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +66 -466
- package/src/runtime/foundation/service-authority-payload-codec.ts +10 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +30 -9
- package/src/runtime/foundation/service-relocation-coordinator.ts +13 -0
- package/src/runtime/foundation/service-relocation-object-owner.ts +18 -5
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +6 -14
- package/src/runtime/foundation/service-stateful-runtime.ts +151 -89
- package/src/runtime/foundation/service-stateful-wire-codec.ts +203 -121
- package/src/runtime/foundation/service-topology-registry.ts +8 -48
- package/src/runtime/host/actor-transfer-runtime.ts +94 -166
- package/src/runtime/host/index.ts +119 -54
- package/src/runtime/host/remote-bound-session-relay.ts +4 -3
- package/src/runtime/host/route-mesh-runtime.ts +9 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +495 -376
- package/src/runtime/host/spot-runtime-options-factory.ts +24 -13
- package/src/runtime/host/stateful-authority-route-runtime.ts +8 -4
- package/src/runtime/host/user-spot-creation-coordinator.ts +147 -142
- package/src/runtime/locations/in-memory-provider-location-store.ts +11 -7
- package/src/runtime/locations/lifecycle.ts +3 -2
- package/src/runtime/locations/resolvers.ts +19 -13
- package/src/runtime/locations/spot-location-claims.ts +5 -34
- package/src/runtime/protocol/service_wire_codec.generated.ts +9 -2
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +6 -6
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +3 -3
- package/src/runtime/spots/index.ts +341 -295
- package/src/runtime/spots/spot-activation-registry.ts +41 -31
- package/src/runtime/spots/spot-activation-state.ts +4 -16
- package/src/runtime/spots/spot-activation.ts +102 -80
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +2 -2
- package/src/runtime/spots/spot-actor-join-dispatch.ts +6 -7
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +20 -18
- package/src/runtime/spots/spot-actor-membership.ts +81 -17
- package/src/runtime/spots/spot-entry-activation.ts +0 -3
- package/src/runtime/spots/spot-manager-public.ts +8 -4
- package/src/runtime/spots/spot-native-actor-join-admission.ts +2 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +12 -18
- package/src/runtime/spots/spot-outbound.ts +4 -47
- package/src/runtime/spots/spot-routed-actor-admission.ts +20 -0
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +6 -76
- package/src/runtime/spots/spot-runtime-ports.ts +6 -17
- package/src/runtime/spots/spot-serial-executor.ts +9 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -4
- package/src/runtime/streams/actor-session-binding-registry.ts +20 -308
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +2 -12
- package/src/runtime/streams/bound-session-service.ts +2 -36
- package/src/runtime/streams/index.ts +29 -27
- package/src/runtime/streams/session-serial-executor.ts +2 -2
- package/dist/runtime/actors/deferred-join-accepted-journal.d.ts +0 -47
- package/dist/runtime/actors/deferred-join-accepted-journal.js +0 -992
- package/src/runtime/actors/deferred-join-accepted-journal.ts +0 -1346
|
@@ -19,6 +19,19 @@ import {
|
|
|
19
19
|
encodeCanonicalServiceWireText,
|
|
20
20
|
encodeServiceWireRoutingId
|
|
21
21
|
} from './service-wire-binary-primitives';
|
|
22
|
+
import {
|
|
23
|
+
decodeActorRequestCommand,
|
|
24
|
+
decodeActorSendCommand,
|
|
25
|
+
decodeMetadataFrame,
|
|
26
|
+
decodeSpotRequestCommand,
|
|
27
|
+
decodeSpotSendCommand,
|
|
28
|
+
encodeActorRequestCommand,
|
|
29
|
+
encodeActorSendCommand,
|
|
30
|
+
encodeApplicationPayloadEnvelopeV1,
|
|
31
|
+
encodeSpotRequestCommand,
|
|
32
|
+
encodeSpotSendCommand,
|
|
33
|
+
type ServiceWireDecoderContext
|
|
34
|
+
} from '../protocol/service_wire_codec.generated';
|
|
22
35
|
import {
|
|
23
36
|
decodeActorCreate49 as decodeGeneratedActorCreate49,
|
|
24
37
|
decodeActorJoin28,
|
|
@@ -337,6 +350,7 @@ export type ServiceSessionRelocationRoute =
|
|
|
337
350
|
readonly targetAuthorityOwnerGeneration: bigint;
|
|
338
351
|
readonly targetNodeRid: string;
|
|
339
352
|
readonly targetNodeGeneration: bigint;
|
|
353
|
+
readonly targetOwnerLeaseGeneration: bigint;
|
|
340
354
|
};
|
|
341
355
|
}
|
|
342
356
|
| {
|
|
@@ -1015,8 +1029,10 @@ export type ServiceStatefulWireRecord =
|
|
|
1015
1029
|
| {
|
|
1016
1030
|
readonly kind: 'spotSend' | 'spotRequest';
|
|
1017
1031
|
readonly correlation?: bigint;
|
|
1032
|
+
readonly operation: ServiceWireOperationId;
|
|
1033
|
+
readonly messageFollowHopCount: number;
|
|
1018
1034
|
readonly sourceSpotId: string;
|
|
1019
|
-
readonly target:
|
|
1035
|
+
readonly target: ServiceSpotRouteFence;
|
|
1020
1036
|
}
|
|
1021
1037
|
| {
|
|
1022
1038
|
readonly kind: 'logicalMulticast';
|
|
@@ -1027,6 +1043,8 @@ export type ServiceStatefulWireRecord =
|
|
|
1027
1043
|
| {
|
|
1028
1044
|
readonly kind: 'actorSend' | 'actorRequest';
|
|
1029
1045
|
readonly correlation?: bigint;
|
|
1046
|
+
readonly operation: ServiceWireOperationId;
|
|
1047
|
+
readonly messageFollowHopCount: number;
|
|
1030
1048
|
readonly sourceActor?: ServiceActorRef;
|
|
1031
1049
|
readonly target: ServiceActorRouteFence;
|
|
1032
1050
|
readonly boundSession?: ServiceBoundSessionSource;
|
|
@@ -1137,20 +1155,68 @@ export interface ServiceStatefulReply {
|
|
|
1137
1155
|
readonly tail?: ServiceStatefulReplyTail;
|
|
1138
1156
|
}
|
|
1139
1157
|
|
|
1158
|
+
const STATEFUL_MESSAGE_CONTEXT: ServiceWireDecoderContext = {
|
|
1159
|
+
effectiveCompleteMessageBytesMinusActualEnvelopeOverhead: 0xffff_fdf6,
|
|
1160
|
+
effectiveCompleteMessageBytes: 0xffff_ffff
|
|
1161
|
+
};
|
|
1162
|
+
const STATEFUL_HEADER_PAYLOAD = {
|
|
1163
|
+
packetName: 'wire',
|
|
1164
|
+
contentType: 'application/json',
|
|
1165
|
+
payload: Buffer.from('{}')
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
function generatedSpotFence(target: ServiceSpotRouteFence) {
|
|
1169
|
+
return {
|
|
1170
|
+
spot: { spotId: target.spot.spotId, objectGeneration: target.spot.generation },
|
|
1171
|
+
targetNodeRid: toGeneratedRoutingId(target.targetNodeRid, 'targetNodeRid'),
|
|
1172
|
+
targetNodeGeneration: target.targetNodeGeneration,
|
|
1173
|
+
expectedAuthorityOwnerGeneration: target.authorityOwnerGeneration,
|
|
1174
|
+
expectedOwnerLeaseGeneration: target.ownerLeaseGeneration
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
function generatedActorFence(target: ServiceActorRouteFence) {
|
|
1179
|
+
return {
|
|
1180
|
+
actor: { actorId: target.actor.actorId, objectGeneration: target.actor.generation },
|
|
1181
|
+
targetNodeRid: toGeneratedRoutingId(target.actor.nodeRid, 'targetNodeRid'),
|
|
1182
|
+
targetNodeGeneration: target.targetNodeGeneration,
|
|
1183
|
+
expectedAuthorityOwnerGeneration: target.authorityOwnerGeneration,
|
|
1184
|
+
expectedOwnerLeaseGeneration: target.ownerLeaseGeneration
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1140
1188
|
export function encodeSpotHeader(
|
|
1141
1189
|
kind: 'spotSend' | 'spotRequest',
|
|
1142
1190
|
sourceSpotId: string,
|
|
1143
1191
|
target: ServiceDirectSpotRouteFence,
|
|
1144
|
-
correlation?: bigint
|
|
1192
|
+
correlation?: bigint,
|
|
1193
|
+
operation: ServiceWireOperationId = { high: 0n, low: 1n },
|
|
1194
|
+
messageFollowHopCount = 0,
|
|
1195
|
+
metadataFrame?: Uint8Array
|
|
1145
1196
|
): Buffer {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1197
|
+
const common = {
|
|
1198
|
+
flags: metadataFrame === undefined ? 0 : M6bServiceWireFlag.metadata,
|
|
1199
|
+
operation,
|
|
1200
|
+
messageFollowHopCount,
|
|
1201
|
+
sourceSpotId,
|
|
1202
|
+
targetSpot: generatedSpotFence(target),
|
|
1203
|
+
payload: STATEFUL_HEADER_PAYLOAD,
|
|
1204
|
+
...(metadataFrame === undefined
|
|
1205
|
+
? {}
|
|
1206
|
+
: { metadata: decodeMetadataFrame(metadataFrame, STATEFUL_MESSAGE_CONTEXT) })
|
|
1207
|
+
};
|
|
1208
|
+
const frames =
|
|
1209
|
+
kind === 'spotSend'
|
|
1210
|
+
? encodeSpotSendCommand({ command: kind, ...common }, STATEFUL_MESSAGE_CONTEXT)
|
|
1211
|
+
: encodeSpotRequestCommand(
|
|
1212
|
+
{
|
|
1213
|
+
command: kind,
|
|
1214
|
+
...common,
|
|
1215
|
+
correlation: requirePositive(correlation, 'correlation')
|
|
1216
|
+
},
|
|
1217
|
+
STATEFUL_MESSAGE_CONTEXT
|
|
1218
|
+
);
|
|
1219
|
+
return Buffer.from(frames[0]!);
|
|
1154
1220
|
}
|
|
1155
1221
|
|
|
1156
1222
|
export function encodeActorHeader(
|
|
@@ -1158,28 +1224,46 @@ export function encodeActorHeader(
|
|
|
1158
1224
|
target: ServiceActorRouteFence,
|
|
1159
1225
|
correlation?: bigint,
|
|
1160
1226
|
sourceActor?: ServiceActorRef,
|
|
1161
|
-
boundSession?: ServiceBoundSessionSource
|
|
1227
|
+
boundSession?: ServiceBoundSessionSource,
|
|
1228
|
+
operation: ServiceWireOperationId = { high: 0n, low: 1n },
|
|
1229
|
+
messageFollowHopCount = 0
|
|
1162
1230
|
): Buffer {
|
|
1163
1231
|
const flags =
|
|
1164
1232
|
boundSession === undefined
|
|
1165
1233
|
? 0
|
|
1166
1234
|
: M6bServiceWireFlag.boundSession | M6bServiceWireFlag.sourceSpotId;
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1235
|
+
const common = {
|
|
1236
|
+
flags,
|
|
1237
|
+
operation,
|
|
1238
|
+
messageFollowHopCount,
|
|
1239
|
+
sourceActor:
|
|
1240
|
+
sourceActor === undefined
|
|
1241
|
+
? { actorId: null }
|
|
1242
|
+
: { actorId: sourceActor.actorId, generation: sourceActor.generation },
|
|
1243
|
+
targetActor: generatedActorFence(target),
|
|
1175
1244
|
...(boundSession === undefined
|
|
1176
|
-
?
|
|
1177
|
-
:
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1245
|
+
? {}
|
|
1246
|
+
: {
|
|
1247
|
+
boundSessionTail: {
|
|
1248
|
+
sourceSessionRid: toGeneratedRoutingId(boundSession.sessionRid, 'sourceSessionRid'),
|
|
1249
|
+
sourceBindingGeneration: boundSession.bindingGeneration,
|
|
1250
|
+
sourceSessionSequence: boundSession.sequence
|
|
1251
|
+
}
|
|
1252
|
+
}),
|
|
1253
|
+
payload: STATEFUL_HEADER_PAYLOAD
|
|
1254
|
+
};
|
|
1255
|
+
const frames =
|
|
1256
|
+
kind === 'actorSend'
|
|
1257
|
+
? encodeActorSendCommand({ command: kind, ...common }, STATEFUL_MESSAGE_CONTEXT)
|
|
1258
|
+
: encodeActorRequestCommand(
|
|
1259
|
+
{
|
|
1260
|
+
command: kind,
|
|
1261
|
+
...common,
|
|
1262
|
+
correlation: requirePositive(correlation, 'correlation')
|
|
1263
|
+
},
|
|
1264
|
+
STATEFUL_MESSAGE_CONTEXT
|
|
1265
|
+
);
|
|
1266
|
+
return Buffer.from(frames[0]!);
|
|
1183
1267
|
}
|
|
1184
1268
|
|
|
1185
1269
|
export function encodeLogicalMulticastHeader(
|
|
@@ -1420,7 +1504,11 @@ export function encodeMessageFollowHeader(
|
|
|
1420
1504
|
);
|
|
1421
1505
|
}
|
|
1422
1506
|
|
|
1423
|
-
export function decodeStatefulHeader(
|
|
1507
|
+
export function decodeStatefulHeader(
|
|
1508
|
+
frame: Uint8Array,
|
|
1509
|
+
payloadFrame?: Uint8Array,
|
|
1510
|
+
metadataFrame?: Uint8Array
|
|
1511
|
+
): ServiceStatefulWireRecord {
|
|
1424
1512
|
switch (frame[3]) {
|
|
1425
1513
|
case M6bServiceWireCommand.userSpotCreate:
|
|
1426
1514
|
return fromGeneratedUserSpotCreate(decodeGeneratedUserSpotCreate47(frame));
|
|
@@ -1428,52 +1516,98 @@ export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireReco
|
|
|
1428
1516
|
return fromGeneratedUserSpotClose(decodeGeneratedUserSpotClose48(frame));
|
|
1429
1517
|
case M6bServiceWireCommand.actorCreate:
|
|
1430
1518
|
return fromGeneratedActorCreate(decodeGeneratedActorCreate49(frame));
|
|
1431
|
-
}
|
|
1432
|
-
const reader = new Reader(frame);
|
|
1433
|
-
const command = reader.prefix();
|
|
1434
|
-
switch (command.command) {
|
|
1435
1519
|
case M6bServiceWireCommand.spotSend:
|
|
1436
|
-
case M6bServiceWireCommand.spotRequest:
|
|
1437
|
-
requireFlags(command.flags, 0);
|
|
1438
|
-
const request = command.command === M6bServiceWireCommand.spotRequest;
|
|
1439
|
-
const correlation = request ? reader.nonZeroU64('correlation') : undefined;
|
|
1440
|
-
const sourceSpotId = reader.rid('sourceSpotId');
|
|
1441
|
-
const target = reader.directSpotFence();
|
|
1442
|
-
reader.end();
|
|
1443
|
-
return {
|
|
1444
|
-
kind: request ? 'spotRequest' : 'spotSend',
|
|
1445
|
-
...(correlation === undefined ? {} : { correlation }),
|
|
1446
|
-
sourceSpotId,
|
|
1447
|
-
target
|
|
1448
|
-
};
|
|
1449
|
-
}
|
|
1520
|
+
case M6bServiceWireCommand.spotRequest:
|
|
1450
1521
|
case M6bServiceWireCommand.actorSend:
|
|
1451
1522
|
case M6bServiceWireCommand.actorRequest: {
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1523
|
+
const frames = [
|
|
1524
|
+
frame,
|
|
1525
|
+
...(metadataFrame === undefined ? [] : [metadataFrame]),
|
|
1526
|
+
payloadFrame ??
|
|
1527
|
+
encodeApplicationPayloadEnvelopeV1(STATEFUL_HEADER_PAYLOAD, STATEFUL_MESSAGE_CONTEXT)
|
|
1528
|
+
];
|
|
1529
|
+
try {
|
|
1530
|
+
if (
|
|
1531
|
+
frame[3] === M6bServiceWireCommand.spotSend ||
|
|
1532
|
+
frame[3] === M6bServiceWireCommand.spotRequest
|
|
1533
|
+
) {
|
|
1534
|
+
const decoded =
|
|
1535
|
+
frame[3] === M6bServiceWireCommand.spotSend
|
|
1536
|
+
? decodeSpotSendCommand(frames, STATEFUL_MESSAGE_CONTEXT)
|
|
1537
|
+
: decodeSpotRequestCommand(frames, STATEFUL_MESSAGE_CONTEXT);
|
|
1538
|
+
return {
|
|
1539
|
+
kind: decoded.command,
|
|
1540
|
+
...(decoded.command === 'spotRequest' ? { correlation: decoded.correlation } : {}),
|
|
1541
|
+
operation: decoded.operation,
|
|
1542
|
+
messageFollowHopCount: decoded.messageFollowHopCount,
|
|
1543
|
+
sourceSpotId: decoded.sourceSpotId,
|
|
1544
|
+
target: {
|
|
1545
|
+
spot: {
|
|
1546
|
+
spotId: decoded.targetSpot.spot.spotId,
|
|
1547
|
+
generation: decoded.targetSpot.spot.objectGeneration
|
|
1548
|
+
},
|
|
1549
|
+
targetNodeRid: fromGeneratedRoutingId(
|
|
1550
|
+
decoded.targetSpot.targetNodeRid,
|
|
1551
|
+
'targetNodeRid'
|
|
1552
|
+
),
|
|
1553
|
+
targetNodeGeneration: decoded.targetSpot.targetNodeGeneration,
|
|
1554
|
+
authorityOwnerGeneration: decoded.targetSpot.expectedAuthorityOwnerGeneration,
|
|
1555
|
+
ownerLeaseGeneration: decoded.targetSpot.expectedOwnerLeaseGeneration
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
const decoded =
|
|
1560
|
+
frame[3] === M6bServiceWireCommand.actorSend
|
|
1561
|
+
? decodeActorSendCommand(frames, STATEFUL_MESSAGE_CONTEXT)
|
|
1562
|
+
: decodeActorRequestCommand(frames, STATEFUL_MESSAGE_CONTEXT);
|
|
1563
|
+
const source = decoded.sourceActor;
|
|
1564
|
+
return {
|
|
1565
|
+
kind: decoded.command,
|
|
1566
|
+
...(decoded.command === 'actorRequest' ? { correlation: decoded.correlation } : {}),
|
|
1567
|
+
operation: decoded.operation,
|
|
1568
|
+
messageFollowHopCount: decoded.messageFollowHopCount,
|
|
1569
|
+
...(source.actorId === null
|
|
1570
|
+
? {}
|
|
1571
|
+
: {
|
|
1572
|
+
sourceActor: {
|
|
1573
|
+
nodeRid: '',
|
|
1574
|
+
actorId: source.actorId,
|
|
1575
|
+
generation: source.generation!
|
|
1576
|
+
}
|
|
1577
|
+
}),
|
|
1578
|
+
target: {
|
|
1579
|
+
actor: {
|
|
1580
|
+
nodeRid: fromGeneratedRoutingId(decoded.targetActor.targetNodeRid, 'targetNodeRid'),
|
|
1581
|
+
actorId: decoded.targetActor.actor.actorId,
|
|
1582
|
+
generation: decoded.targetActor.actor.objectGeneration
|
|
1583
|
+
},
|
|
1584
|
+
targetNodeGeneration: decoded.targetActor.targetNodeGeneration,
|
|
1585
|
+
authorityOwnerGeneration: decoded.targetActor.expectedAuthorityOwnerGeneration,
|
|
1586
|
+
ownerLeaseGeneration: decoded.targetActor.expectedOwnerLeaseGeneration
|
|
1587
|
+
},
|
|
1588
|
+
...(decoded.boundSessionTail === undefined
|
|
1589
|
+
? {}
|
|
1590
|
+
: {
|
|
1591
|
+
boundSession: {
|
|
1592
|
+
sessionRid: fromGeneratedRoutingId(
|
|
1593
|
+
decoded.boundSessionTail.sourceSessionRid,
|
|
1594
|
+
'sourceSessionRid'
|
|
1595
|
+
),
|
|
1596
|
+
bindingGeneration: decoded.boundSessionTail.sourceBindingGeneration,
|
|
1597
|
+
sequence: decoded.boundSessionTail.sourceSessionSequence
|
|
1598
|
+
}
|
|
1599
|
+
})
|
|
1600
|
+
};
|
|
1601
|
+
} catch (error) {
|
|
1602
|
+
throw new ServiceWireProtocolError(
|
|
1603
|
+
error instanceof Error ? error.message : 'Invalid stateful message.'
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1476
1606
|
}
|
|
1607
|
+
}
|
|
1608
|
+
const reader = new Reader(frame);
|
|
1609
|
+
const command = reader.prefix();
|
|
1610
|
+
switch (command.command) {
|
|
1477
1611
|
case M6bServiceWireCommand.logicalMulticast: {
|
|
1478
1612
|
requireFlags(command.flags, 0);
|
|
1479
1613
|
const result = {
|
|
@@ -2124,20 +2258,6 @@ function actorAuthorityFence(value: ServiceBoundSessionActorAuthority): Buffer {
|
|
|
2124
2258
|
);
|
|
2125
2259
|
}
|
|
2126
2260
|
|
|
2127
|
-
function spotFence(value: ServiceSpotRouteFence): Buffer {
|
|
2128
|
-
return concat(
|
|
2129
|
-
spotRef(value.spot),
|
|
2130
|
-
rid(value.targetNodeRid, 'targetNodeRid'),
|
|
2131
|
-
u64(value.targetNodeGeneration),
|
|
2132
|
-
u64(value.authorityOwnerGeneration),
|
|
2133
|
-
u64(value.ownerLeaseGeneration)
|
|
2134
|
-
);
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
function directSpotFence(value: ServiceDirectSpotRouteFence): Buffer {
|
|
2138
|
-
return concat(spotFence(value), text16(value.storeVersion, 'storeVersion'));
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
2261
|
function messageFollowRoute(value: ServiceMessageFollowRoute): Buffer {
|
|
2142
2262
|
const body =
|
|
2143
2263
|
value.kind === 'actor'
|
|
@@ -2205,12 +2325,6 @@ function actorRef(value: ServiceActorRef): Buffer {
|
|
|
2205
2325
|
return concat(text8(value.actorId, 'actorId'), u64(value.generation));
|
|
2206
2326
|
}
|
|
2207
2327
|
|
|
2208
|
-
function optionalActor(value: ServiceActorRef | undefined): Buffer {
|
|
2209
|
-
return value === undefined
|
|
2210
|
-
? Buffer.of(0)
|
|
2211
|
-
: concat(text8(value.actorId, 'sourceActorId'), u64(value.generation));
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
2328
|
function spotRef(value: ServiceSpotRef): Buffer {
|
|
2215
2329
|
return concat(rid(value.spotId, 'spotId'), u64(value.generation));
|
|
2216
2330
|
}
|
|
@@ -2409,20 +2523,6 @@ class Reader {
|
|
|
2409
2523
|
};
|
|
2410
2524
|
}
|
|
2411
2525
|
|
|
2412
|
-
optionalActor(): ServiceActorRef | undefined {
|
|
2413
|
-
const length = this.u8('sourceActorId.length');
|
|
2414
|
-
if (length === 0) return undefined;
|
|
2415
|
-
this.need(length, 'sourceActorId');
|
|
2416
|
-
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2417
|
-
this.offset += length;
|
|
2418
|
-
const actorId = decodeCanonicalServiceWireText(bytes, 'sourceActorId', fail);
|
|
2419
|
-
return {
|
|
2420
|
-
nodeRid: '',
|
|
2421
|
-
actorId,
|
|
2422
|
-
generation: this.nonZeroU64('sourceActorGeneration')
|
|
2423
|
-
};
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
2526
|
spotRef(): ServiceSpotRef {
|
|
2427
2527
|
return {
|
|
2428
2528
|
spotId: this.rid('spotId'),
|
|
@@ -2441,24 +2541,6 @@ class Reader {
|
|
|
2441
2541
|
};
|
|
2442
2542
|
}
|
|
2443
2543
|
|
|
2444
|
-
spotFence(): ServiceSpotRouteFence {
|
|
2445
|
-
const spot = this.spotRef();
|
|
2446
|
-
return {
|
|
2447
|
-
spot,
|
|
2448
|
-
targetNodeRid: this.rid('targetNodeRid'),
|
|
2449
|
-
targetNodeGeneration: this.nonZeroU64('targetNodeGeneration'),
|
|
2450
|
-
authorityOwnerGeneration: this.nonZeroU64('authorityOwnerGeneration'),
|
|
2451
|
-
ownerLeaseGeneration: this.nonZeroU64('ownerLeaseGeneration')
|
|
2452
|
-
};
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
|
-
directSpotFence(): ServiceDirectSpotRouteFence {
|
|
2456
|
-
return {
|
|
2457
|
-
...this.spotFence(),
|
|
2458
|
-
storeVersion: this.text16('storeVersion')
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
2544
|
messageFollowRoute(name: string): ServiceMessageFollowRoute {
|
|
2463
2545
|
const kind = this.u8(`${name}.objectKind`);
|
|
2464
2546
|
const length = this.u16(`${name}.length`);
|
|
@@ -34,8 +34,9 @@ export interface ServiceNodeDescriptor {
|
|
|
34
34
|
|
|
35
35
|
export interface AdmittedServicePeer {
|
|
36
36
|
readonly descriptor: ServiceNodeDescriptor;
|
|
37
|
+
// The Core selected-route generation this admission belongs to (Core ROUTER
|
|
38
|
+
// §10.1), as an opaque token compared only for equality.
|
|
37
39
|
readonly connectionId: string;
|
|
38
|
-
readonly connectionDiscriminator: string;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export interface ServicePeerAdmissionExpectation {
|
|
@@ -98,13 +99,11 @@ export class ServiceTopologyRegistry {
|
|
|
98
99
|
admit(
|
|
99
100
|
descriptor: ServiceNodeDescriptor,
|
|
100
101
|
connectionId: string,
|
|
101
|
-
expected?: ServicePeerAdmissionExpectation
|
|
102
|
-
connectionDiscriminator = connectionId
|
|
102
|
+
expected?: ServicePeerAdmissionExpectation
|
|
103
103
|
): PeerAdmissionResult {
|
|
104
104
|
try {
|
|
105
105
|
validateDescriptor(descriptor);
|
|
106
106
|
requireText(connectionId, 'connectionId');
|
|
107
|
-
requireText(connectionDiscriminator, 'connectionDiscriminator');
|
|
108
107
|
} catch (error) {
|
|
109
108
|
return 'invalidDescriptor';
|
|
110
109
|
}
|
|
@@ -146,34 +145,11 @@ export class ServiceTopologyRegistry {
|
|
|
146
145
|
) {
|
|
147
146
|
return 'staleDescriptor';
|
|
148
147
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
current.descriptor.lifecycleGeneration === descriptor.lifecycleGeneration &&
|
|
152
|
-
current.descriptor.descriptorRevision === descriptor.descriptorRevision &&
|
|
153
|
-
sameServiceNodeDescriptor(current.descriptor, descriptor) &&
|
|
154
|
-
current.connectionId !== connectionId &&
|
|
155
|
-
// A fallback candidate is only a logical placeholder. Once the
|
|
156
|
-
// monitor reports the physical connection, its evidence supersedes
|
|
157
|
-
// candidate ordering so the request path uses the native route.
|
|
158
|
-
!(
|
|
159
|
-
isUnmonitoredConnectionId(current.connectionId) && !isUnmonitoredConnectionId(connectionId)
|
|
160
|
-
) &&
|
|
161
|
-
compareConnectionCandidate(
|
|
162
|
-
current.connectionDiscriminator,
|
|
163
|
-
current.connectionId,
|
|
164
|
-
connectionDiscriminator,
|
|
165
|
-
connectionId
|
|
166
|
-
) <= 0
|
|
167
|
-
) {
|
|
168
|
-
// Both manual directions can reach admission. The same comparison on
|
|
169
|
-
// every retry keeps one physical candidate instead of replacing it in
|
|
170
|
-
// arrival order.
|
|
171
|
-
return 'staleDescriptor';
|
|
172
|
-
}
|
|
148
|
+
// Core selects the one route per RID (Core ROUTER §10.1); an admission on
|
|
149
|
+
// that route replaces the admission of a route it replaced.
|
|
173
150
|
this.peersByRid.set(descriptor.nodeRoutingId, {
|
|
174
151
|
descriptor: cloneDescriptor(descriptor),
|
|
175
|
-
connectionId
|
|
176
|
-
connectionDiscriminator
|
|
152
|
+
connectionId
|
|
177
153
|
});
|
|
178
154
|
this.remember(descriptor);
|
|
179
155
|
this.rebuildSelections();
|
|
@@ -286,8 +262,7 @@ export class ServiceTopologyRegistry {
|
|
|
286
262
|
() => {
|
|
287
263
|
const local: AdmittedServicePeer = {
|
|
288
264
|
descriptor: cloneDescriptor(this.local),
|
|
289
|
-
connectionId: 'local'
|
|
290
|
-
connectionDiscriminator: 'local'
|
|
265
|
+
connectionId: 'local'
|
|
291
266
|
};
|
|
292
267
|
return [local, ...this.peersByRid.values()]
|
|
293
268
|
.map((peer) => ({
|
|
@@ -549,8 +524,7 @@ function cloneDescriptor(descriptor: ServiceNodeDescriptor): ServiceNodeDescript
|
|
|
549
524
|
function clonePeer(peer: AdmittedServicePeer): AdmittedServicePeer {
|
|
550
525
|
return {
|
|
551
526
|
descriptor: cloneDescriptor(peer.descriptor),
|
|
552
|
-
connectionId: peer.connectionId
|
|
553
|
-
connectionDiscriminator: peer.connectionDiscriminator
|
|
527
|
+
connectionId: peer.connectionId
|
|
554
528
|
};
|
|
555
529
|
}
|
|
556
530
|
|
|
@@ -582,20 +556,6 @@ function arraysEqual(left: readonly string[], right: readonly string[]): boolean
|
|
|
582
556
|
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
583
557
|
}
|
|
584
558
|
|
|
585
|
-
function isUnmonitoredConnectionId(connectionId: string): boolean {
|
|
586
|
-
return connectionId.startsWith('unmonitored:');
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function compareConnectionCandidate(
|
|
590
|
-
leftDiscriminator: string,
|
|
591
|
-
leftId: string,
|
|
592
|
-
rightDiscriminator: string,
|
|
593
|
-
rightId: string
|
|
594
|
-
): number {
|
|
595
|
-
const discriminator = compareOrdinal(leftDiscriminator, rightDiscriminator);
|
|
596
|
-
return discriminator === 0 ? compareOrdinal(leftId, rightId) : discriminator;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
559
|
function compareOrdinal(left: string, right: string): number {
|
|
600
560
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
601
561
|
}
|