@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
|
@@ -29,15 +29,12 @@ function inspectMalformedChannelHeader(parts, flowEnabled) {
|
|
|
29
29
|
catch {
|
|
30
30
|
return {};
|
|
31
31
|
}
|
|
32
|
-
if (header.formatMarker !== channel_envelope_1.ZLINK_CHANNEL_FORMAT_MARKER)
|
|
33
|
-
return {};
|
|
34
32
|
const flowId = typeof header.flowId === 'string' && CHANNEL_FLOW_ID_PATTERN.test(header.flowId)
|
|
35
33
|
? header.flowId
|
|
36
34
|
: undefined;
|
|
37
35
|
const flowOrigin = salvageFlowOrigin(header.flowOrigin);
|
|
38
36
|
const flowPairValid = flowEnabled && flowId !== undefined && flowOrigin !== undefined;
|
|
39
37
|
return {
|
|
40
|
-
kind: salvageChannelKind(header.kind),
|
|
41
38
|
channelName: salvageString(header.channelName),
|
|
42
39
|
messageName: salvageString(header.messageName),
|
|
43
40
|
correlationId: salvageCorrelationId(header.correlationId),
|
|
@@ -66,23 +63,11 @@ function malformedProtocolErrorRequestHeader(channelName, info) {
|
|
|
66
63
|
};
|
|
67
64
|
}
|
|
68
65
|
const CHANNEL_FLOW_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
69
|
-
function salvageChannelKind(value) {
|
|
70
|
-
return value === 1 /* ZLinkChannelMessageKind.Request */ ||
|
|
71
|
-
value === 2 /* ZLinkChannelMessageKind.Response */ ||
|
|
72
|
-
value === 3 /* ZLinkChannelMessageKind.Command */ ||
|
|
73
|
-
value === 4 /* ZLinkChannelMessageKind.Publish */ ||
|
|
74
|
-
value === 5 /* ZLinkChannelMessageKind.Error */
|
|
75
|
-
? value
|
|
76
|
-
: undefined;
|
|
77
|
-
}
|
|
78
66
|
function salvageString(value) {
|
|
79
67
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
80
68
|
}
|
|
81
69
|
function salvageCorrelationId(value) {
|
|
82
|
-
|
|
83
|
-
return undefined;
|
|
84
|
-
const byteLength = Buffer.byteLength(value, 'utf8');
|
|
85
|
-
return byteLength >= 1 && byteLength <= 64 && /^[\x00-\x7f]*$/.test(value) ? value : undefined;
|
|
70
|
+
return typeof value === 'string' && (0, channel_envelope_1.isValidChannelCorrelationId)(value) ? value : undefined;
|
|
86
71
|
}
|
|
87
72
|
function salvageFlowOrigin(value) {
|
|
88
73
|
switch (value) {
|
|
@@ -71,3 +71,4 @@ export declare function decodeChannelEnvelope(parts: readonly Message[], decoded
|
|
|
71
71
|
export declare function decodeChannelPayload(envelope: ZLinkChannelEnvelope, codecs?: ZLinkChannelEnvelopeCodecRegistry): unknown;
|
|
72
72
|
export declare function closeMessages(parts: readonly MessageLike[]): void;
|
|
73
73
|
export declare function decodeChannelHeader(parts: readonly Message[], flowEnabled?: boolean): ZLinkChannelEnvelopeHeader;
|
|
74
|
+
export declare function isValidChannelCorrelationId(value: string): boolean;
|
|
@@ -13,6 +13,8 @@ exports.decodeChannelEnvelope = decodeChannelEnvelope;
|
|
|
13
13
|
exports.decodeChannelPayload = decodeChannelPayload;
|
|
14
14
|
exports.closeMessages = closeMessages;
|
|
15
15
|
exports.decodeChannelHeader = decodeChannelHeader;
|
|
16
|
+
exports.isValidChannelCorrelationId = isValidChannelCorrelationId;
|
|
17
|
+
const runtime_message_1 = require("../backend/runtime-message");
|
|
16
18
|
const node_crypto_1 = require("node:crypto");
|
|
17
19
|
const node_buffer_1 = require("node:buffer");
|
|
18
20
|
const contracts_1 = require("../../contracts");
|
|
@@ -34,6 +36,13 @@ exports.ZLINK_CHANNEL_FORMAT_MARKER = 0xf2;
|
|
|
34
36
|
const EMPTY_OUTBOUND_METADATA = new Map();
|
|
35
37
|
exports.JSON_CONTENT_TYPE = 'application/json';
|
|
36
38
|
exports.BINARY_CONTENT_TYPE = 'application/octet-stream';
|
|
39
|
+
const preparedChannelHeaders = new WeakMap();
|
|
40
|
+
const CHANNEL_CORRELATION_FIELD = ',"correlationId":';
|
|
41
|
+
const CHANNEL_DEADLINE_FIELD = ',"deadline":';
|
|
42
|
+
const CHANNEL_CORRELATION_TEXT_LENGTH = 32;
|
|
43
|
+
const PREPARED_CHANNEL_CORRELATION = '0'.repeat(CHANNEL_CORRELATION_TEXT_LENGTH);
|
|
44
|
+
const PREPARED_CHANNEL_DEADLINE = '2000-01-01T00:00:00.000Z';
|
|
45
|
+
const CHANNEL_CORRELATION_TEXT = /^[0-9a-f]{32}$/;
|
|
37
46
|
function newChannelCorrelationId() {
|
|
38
47
|
return (0, node_crypto_1.randomUUID)().replaceAll('-', '');
|
|
39
48
|
}
|
|
@@ -56,7 +65,7 @@ function encodeChannelEnvelopePartsAtDeadline(kind, channelName, packetName, pay
|
|
|
56
65
|
const flow = createFlow ? (0, flow_context_1.currentOrCreateFlow)('Application') : undefined;
|
|
57
66
|
const envelopeCorrelationId = correlationIdForOutboundKind(kind, correlationId);
|
|
58
67
|
return [
|
|
59
|
-
encodeChannelHeader(kind, channelName, messageName, encoded.contentType, envelopeCorrelationId, deadlineUnixMs === undefined ? null : new Date(deadlineUnixMs).toISOString(), topic ?? null, null, null, undefined, applicationMetadataRecord(metadata), flow?.flowId, flow?.flowOrigin),
|
|
68
|
+
encodeChannelHeader(kind, channelName, messageName, encoded.contentType, envelopeCorrelationId, deadlineUnixMs === undefined ? null : new Date(deadlineUnixMs).toISOString(), topic ?? null, null, null, undefined, applicationMetadataRecord(metadata), flow?.flowId, flow?.flowOrigin, codecs),
|
|
60
69
|
encoded.message
|
|
61
70
|
];
|
|
62
71
|
}
|
|
@@ -72,7 +81,7 @@ function encodeChannelPublishEnvelopeParts(channelName, topic, packetName, paylo
|
|
|
72
81
|
function encodeChannelReplyParts(request, payload, codecs) {
|
|
73
82
|
const encoded = encodePayload(payload ?? Buffer.alloc(0), (0, channel_framework_packets_1.codecsForFrameworkPacket)(request.messageName, codecs), request.messageName, 'reply');
|
|
74
83
|
return [
|
|
75
|
-
encodeChannelHeader(2 /* ZLinkChannelMessageKind.Response */, request.channelName, request.messageName, encoded.contentType, request.correlationId, null, null, undefined, undefined, undefined, EMPTY_APPLICATION_METADATA, request.flowId, request.flowOrigin),
|
|
84
|
+
encodeChannelHeader(2 /* ZLinkChannelMessageKind.Response */, request.channelName, request.messageName, encoded.contentType, request.correlationId, null, null, undefined, undefined, undefined, EMPTY_APPLICATION_METADATA, request.flowId, request.flowOrigin, codecs),
|
|
76
85
|
encoded.message
|
|
77
86
|
];
|
|
78
87
|
}
|
|
@@ -137,7 +146,7 @@ function decodeChannelReply(parts, codecs) {
|
|
|
137
146
|
return undefined;
|
|
138
147
|
}
|
|
139
148
|
if (header.contentType === exports.BINARY_CONTENT_TYPE) {
|
|
140
|
-
return
|
|
149
|
+
return runtime_message_1.ZLinkBufferMessage.retainPayload(parts[1]);
|
|
141
150
|
}
|
|
142
151
|
if (serializer !== undefined) {
|
|
143
152
|
return serializer.deserialize(contracts_1.ZLinkEncodedPayload.from(parts[1].data()), Object);
|
|
@@ -270,7 +279,33 @@ function isMessage(value) {
|
|
|
270
279
|
function encodeJsonBytes(value, schema) {
|
|
271
280
|
return Buffer.from((0, framework_json_v1_1.stringifyFrameworkJsonV1)(value, schema));
|
|
272
281
|
}
|
|
273
|
-
function encodeChannelHeader(kind, channelName, messageName, contentType, correlationId, deadline, topic, errorCode, errorMessage, source, metadata, flowId, flowOrigin) {
|
|
282
|
+
function encodeChannelHeader(kind, channelName, messageName, contentType, correlationId, deadline, topic, errorCode, errorMessage, source, metadata, flowId, flowOrigin, codecs) {
|
|
283
|
+
if (codecs !== undefined &&
|
|
284
|
+
metadata === EMPTY_APPLICATION_METADATA &&
|
|
285
|
+
flowId === undefined &&
|
|
286
|
+
flowOrigin === undefined &&
|
|
287
|
+
topic === null &&
|
|
288
|
+
source === undefined &&
|
|
289
|
+
((kind === 3 /* ZLinkChannelMessageKind.Command */ &&
|
|
290
|
+
correlationId === null &&
|
|
291
|
+
deadline === null &&
|
|
292
|
+
errorCode === null &&
|
|
293
|
+
errorMessage === null) ||
|
|
294
|
+
(kind === 1 /* ZLinkChannelMessageKind.Request */ &&
|
|
295
|
+
correlationId !== null &&
|
|
296
|
+
CHANNEL_CORRELATION_TEXT.test(correlationId) &&
|
|
297
|
+
deadline !== null &&
|
|
298
|
+
deadline.length === PREPARED_CHANNEL_DEADLINE.length &&
|
|
299
|
+
errorCode === null &&
|
|
300
|
+
errorMessage === null) ||
|
|
301
|
+
(kind === 2 /* ZLinkChannelMessageKind.Response */ &&
|
|
302
|
+
correlationId !== null &&
|
|
303
|
+
CHANNEL_CORRELATION_TEXT.test(correlationId) &&
|
|
304
|
+
deadline === null &&
|
|
305
|
+
errorCode === undefined &&
|
|
306
|
+
errorMessage === undefined))) {
|
|
307
|
+
return preparedChannelHeader(codecs, kind, channelName, messageName, contentType, correlationId, deadline, errorCode, errorMessage);
|
|
308
|
+
}
|
|
274
309
|
// The wire has a fixed field order. Measure escaped UTF-8 first, then write
|
|
275
310
|
// each field once into the only header Buffer: no header object, whole JSON
|
|
276
311
|
// string, or post-encode byte copy exists on the outbound path.
|
|
@@ -281,6 +316,42 @@ function encodeChannelHeader(kind, channelName, messageName, contentType, correl
|
|
|
281
316
|
writeChannelHeader(writer, kind, channelName, messageName, contentType, correlationId, deadline, topic, errorCode, errorMessage, source, metadata, flowId, flowOrigin);
|
|
282
317
|
return result;
|
|
283
318
|
}
|
|
319
|
+
function preparedChannelHeader(codecs, kind, channelName, messageName, contentType, correlationId, deadline, errorCode, errorMessage) {
|
|
320
|
+
let channels = preparedChannelHeaders.get(codecs.serializers);
|
|
321
|
+
if (channels === undefined)
|
|
322
|
+
preparedChannelHeaders.set(codecs.serializers, (channels = new Map()));
|
|
323
|
+
let packets = channels.get(channelName);
|
|
324
|
+
if (packets === undefined)
|
|
325
|
+
channels.set(channelName, (packets = new Map()));
|
|
326
|
+
let contentTypes = packets.get(messageName);
|
|
327
|
+
if (contentTypes === undefined)
|
|
328
|
+
packets.set(messageName, (contentTypes = new Map()));
|
|
329
|
+
let kinds = contentTypes.get(contentType);
|
|
330
|
+
if (kinds === undefined)
|
|
331
|
+
contentTypes.set(contentType, (kinds = new Map()));
|
|
332
|
+
let deadlines = kinds.get(kind);
|
|
333
|
+
if (deadlines === undefined)
|
|
334
|
+
kinds.set(kind, (deadlines = new Map()));
|
|
335
|
+
const hasDeadline = deadline !== null;
|
|
336
|
+
let prepared = deadlines.get(hasDeadline);
|
|
337
|
+
if (prepared === undefined) {
|
|
338
|
+
const bytes = encodeChannelHeader(kind, channelName, messageName, contentType, correlationId === null ? null : PREPARED_CHANNEL_CORRELATION, hasDeadline ? PREPARED_CHANNEL_DEADLINE : null, null, errorCode, errorMessage, undefined, EMPTY_APPLICATION_METADATA, undefined, undefined);
|
|
339
|
+
prepared = {
|
|
340
|
+
bytes,
|
|
341
|
+
correlationOffset: bytes.indexOf(CHANNEL_CORRELATION_FIELD) + CHANNEL_CORRELATION_FIELD.length + 1,
|
|
342
|
+
deadlineOffset: bytes.indexOf(CHANNEL_DEADLINE_FIELD) + CHANNEL_DEADLINE_FIELD.length + 1
|
|
343
|
+
};
|
|
344
|
+
deadlines.set(hasDeadline, prepared);
|
|
345
|
+
}
|
|
346
|
+
if (correlationId === null)
|
|
347
|
+
return prepared.bytes;
|
|
348
|
+
const bytes = Buffer.alloc(prepared.bytes.byteLength);
|
|
349
|
+
prepared.bytes.copy(bytes);
|
|
350
|
+
bytes.write(correlationId, prepared.correlationOffset, CHANNEL_CORRELATION_TEXT_LENGTH, 'ascii');
|
|
351
|
+
if (deadline !== null)
|
|
352
|
+
bytes.write(deadline, prepared.deadlineOffset, PREPARED_CHANNEL_DEADLINE.length, 'ascii');
|
|
353
|
+
return bytes;
|
|
354
|
+
}
|
|
284
355
|
function writeChannelHeader(writer, kind, channelName, messageName, contentType, correlationId, deadline, topic, errorCode, errorMessage, source, metadata, flowId, flowOrigin) {
|
|
285
356
|
writer.append('{"formatMarker":');
|
|
286
357
|
writer.append(String(exports.ZLINK_CHANNEL_FORMAT_MARKER));
|
|
@@ -292,9 +363,9 @@ function writeChannelHeader(writer, kind, channelName, messageName, contentType,
|
|
|
292
363
|
writer.string(messageName);
|
|
293
364
|
writer.append(',"contentType":');
|
|
294
365
|
writer.string(contentType);
|
|
295
|
-
writer.append(
|
|
366
|
+
writer.append(CHANNEL_CORRELATION_FIELD);
|
|
296
367
|
writer.nullableString(correlationId);
|
|
297
|
-
writer.append(
|
|
368
|
+
writer.append(CHANNEL_DEADLINE_FIELD);
|
|
298
369
|
writer.nullableString(deadline);
|
|
299
370
|
writer.append(',"topic":');
|
|
300
371
|
writer.nullableString(topic);
|
|
@@ -681,9 +752,13 @@ function validateCorrelationForKind(kind, correlationId) {
|
|
|
681
752
|
throw new configuration_1.ZLinkConfigurationException(`Channel ${channelKindName(kind)} must not contain correlationId.`);
|
|
682
753
|
}
|
|
683
754
|
}
|
|
755
|
+
const MAXIMUM_CORRELATION_ID_BYTES = 64;
|
|
756
|
+
function isValidChannelCorrelationId(value) {
|
|
757
|
+
const byteLength = Buffer.byteLength(value, 'utf8');
|
|
758
|
+
return (byteLength >= 1 && byteLength <= MAXIMUM_CORRELATION_ID_BYTES && /^[\x00-\x7f]*$/.test(value));
|
|
759
|
+
}
|
|
684
760
|
function validateCorrelationValue(correlationId) {
|
|
685
|
-
|
|
686
|
-
if (byteLength < 1 || byteLength > 64 || !/^[\x00-\x7f]*$/.test(correlationId)) {
|
|
761
|
+
if (!isValidChannelCorrelationId(correlationId)) {
|
|
687
762
|
throw new configuration_1.ZLinkConfigurationException('Channel envelope correlationId must be a non-empty ASCII value of at most 64 bytes.');
|
|
688
763
|
}
|
|
689
764
|
}
|
|
@@ -13,7 +13,7 @@ export declare class ZLinkChannelOutboundOperations {
|
|
|
13
13
|
send(channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
14
14
|
private sendScoped;
|
|
15
15
|
private traceSend;
|
|
16
|
-
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string
|
|
16
|
+
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): Promise<TReply>;
|
|
17
17
|
private requestScoped;
|
|
18
18
|
tryPublish(channelName: string, topic: string, packetName: string | undefined, event: unknown, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
19
19
|
private tryPublishScoped;
|
|
@@ -22,7 +22,7 @@ export declare class ZLinkChannelOutboundOperations {
|
|
|
22
22
|
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
23
23
|
private routeSubmitScoped;
|
|
24
24
|
private traceRouteSend;
|
|
25
|
-
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string
|
|
25
|
+
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): Promise<TReply>;
|
|
26
26
|
private routeRequestScoped;
|
|
27
27
|
private measureRequest;
|
|
28
28
|
}
|
|
@@ -68,10 +68,10 @@ class ZLinkChannelOutboundOperations {
|
|
|
68
68
|
correlationId: undefined
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
request(channelName, packetName, request, timeoutMs, signal, metadata) {
|
|
72
|
-
return keepChannelRequestAlive((0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.requestScoped(channelName, packetName, request, timeoutMs, signal, metadata)));
|
|
71
|
+
request(channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
72
|
+
return keepChannelRequestAlive((0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.requestScoped(channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted)));
|
|
73
73
|
}
|
|
74
|
-
async requestScoped(channelName, packetName, request, timeoutMs, signal, metadata) {
|
|
74
|
+
async requestScoped(channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
75
75
|
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
76
76
|
const deadlineUnixMs = timeoutMs === undefined ? undefined : Date.now() + timeoutMs;
|
|
77
77
|
let correlationId;
|
|
@@ -117,7 +117,7 @@ class ZLinkChannelOutboundOperations {
|
|
|
117
117
|
let replyParts = [];
|
|
118
118
|
try {
|
|
119
119
|
try {
|
|
120
|
-
replyParts = await (0, abort_1.awaitWithAbort)(dealer.request(parts, (0, request_deadline_1.remainingRequestTimeout)(`Channel request '${channelName}'`, deadlineMs)), signal);
|
|
120
|
+
replyParts = await (0, abort_1.awaitWithAbort)(dealer.request(parts, (0, request_deadline_1.remainingRequestTimeout)(`Channel request '${channelName}'`, deadlineMs), onAdmitted), signal);
|
|
121
121
|
}
|
|
122
122
|
catch (error) {
|
|
123
123
|
if (signal?.aborted === true)
|
|
@@ -205,10 +205,10 @@ class ZLinkChannelOutboundOperations {
|
|
|
205
205
|
targetRid: targetNodeRid
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
-
routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata) {
|
|
209
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.routeRequestScoped(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata));
|
|
208
|
+
routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
209
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.routeRequestScoped(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata, onAdmitted));
|
|
210
210
|
}
|
|
211
|
-
async routeRequestScoped(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata) {
|
|
211
|
+
async routeRequestScoped(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
212
212
|
let correlationId;
|
|
213
213
|
let router;
|
|
214
214
|
let terminalRecorded = false;
|
|
@@ -245,7 +245,7 @@ class ZLinkChannelOutboundOperations {
|
|
|
245
245
|
targetRid: targetNodeRid
|
|
246
246
|
});
|
|
247
247
|
const reply = await this.measureRequest(routerChannelId, async () => {
|
|
248
|
-
const replyParts = await (0, abort_1.awaitWithAbort)(router.request(targetNodeRid, parts, timeoutMs), signal);
|
|
248
|
+
const replyParts = await (0, abort_1.awaitWithAbort)(router.request(targetNodeRid, parts, timeoutMs, onAdmitted), signal);
|
|
249
249
|
try {
|
|
250
250
|
return (0, channel_envelope_1.decodeChannelReply)(replyParts, this.codecs);
|
|
251
251
|
}
|
|
@@ -258,7 +258,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
258
258
|
}
|
|
259
259
|
async acquirePermit(signal) {
|
|
260
260
|
try {
|
|
261
|
-
return await this.applicationJobQueue.acquire(signal);
|
|
261
|
+
return await this.applicationJobQueue.acquire(signal, 'remote');
|
|
262
262
|
}
|
|
263
263
|
catch (error) {
|
|
264
264
|
if (this.isStopped() || signal.aborted)
|
|
@@ -448,7 +448,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
448
448
|
}
|
|
449
449
|
async acquirePermit(signal) {
|
|
450
450
|
try {
|
|
451
|
-
return await this.applicationJobQueue.acquire(signal);
|
|
451
|
+
return await this.applicationJobQueue.acquire(signal, 'remote');
|
|
452
452
|
}
|
|
453
453
|
catch (error) {
|
|
454
454
|
if (this.isStopped() || signal.aborted)
|
|
@@ -640,7 +640,7 @@ class ZLinkRouteReceiveLoop {
|
|
|
640
640
|
}
|
|
641
641
|
async acquirePermit(signal) {
|
|
642
642
|
try {
|
|
643
|
-
return await this.applicationJobQueue.acquire(signal);
|
|
643
|
+
return await this.applicationJobQueue.acquire(signal, 'remote');
|
|
644
644
|
}
|
|
645
645
|
catch (error) {
|
|
646
646
|
if (this.isStopped() || signal.aborted)
|
|
@@ -332,7 +332,8 @@ class ZLinkChannelRuntimeLifecycle {
|
|
|
332
332
|
unhandled: this.options.registration.dispatch?.unhandled
|
|
333
333
|
});
|
|
334
334
|
const spotRouteBridge = this.createSpotRouteBridgeForRouter(channelName, router);
|
|
335
|
-
const
|
|
335
|
+
const serverPeers = this.options.sockets.clientServerServerPeersForChannel(channelName);
|
|
336
|
+
const loop = new channel_receive_loops_1.ZLinkChannelReceiveLoop(channelName, router, dispatcher, spotRouteBridge, (received, socket) => this.options.sockets.tryHandleClientServerControl(channelName, received, socket, serverPeers), this.options.adapter.createReadablePoller(router), this.options.applicationJobQueue, (error) => taskRunner.errorSink.reportRuntimeTaskException(`channel:${channelName}:dispatch`, error), this.receiveRoundRobin, this.applicationDispatchQueue(channelName));
|
|
336
337
|
this.channelReceiveLoops.push(loop);
|
|
337
338
|
tasks.push(taskRunner.run(`channel:${channelName}`, (signal) => loop.run(signal)));
|
|
338
339
|
}
|
|
@@ -45,17 +45,17 @@ export declare class ZLinkChannelRuntimeManager {
|
|
|
45
45
|
dispatchLocalMeshRoute(meshName: string, sourceNodeRid: RoutingId, parts: readonly Message[], signal?: AbortSignal): Promise<void>;
|
|
46
46
|
canDispatchLocalMeshRoute(meshName: string): boolean;
|
|
47
47
|
send(channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
48
|
-
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string
|
|
48
|
+
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): Promise<TReply>;
|
|
49
49
|
tryPublish(channelName: string, topic: string, packetName: string | undefined, event: unknown, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
50
50
|
publish(channelName: string, topic: string, packetName: string | undefined, event: unknown, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
51
51
|
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
52
|
-
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string
|
|
52
|
+
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): Promise<TReply>;
|
|
53
53
|
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
54
|
-
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string
|
|
55
|
-
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
54
|
+
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): Promise<TReply>;
|
|
55
|
+
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, onAdmitted?: () => void): Promise<TReply>;
|
|
56
56
|
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
57
|
-
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
58
|
-
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
57
|
+
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
58
|
+
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
59
59
|
canRouteChannel(routerChannelId: string): boolean;
|
|
60
60
|
canRoutePacketChannel(routerChannelId: string): boolean;
|
|
61
61
|
dispose(signal?: AbortSignal): Promise<void>;
|
|
@@ -141,8 +141,8 @@ class ZLinkChannelRuntimeManager {
|
|
|
141
141
|
send(channelName, packetName, message, metadata) {
|
|
142
142
|
return this.outbound.send(channelName, packetName, message, metadata);
|
|
143
143
|
}
|
|
144
|
-
async request(channelName, packetName, request, timeoutMs, signal, metadata) {
|
|
145
|
-
return this.outbound.request(channelName, packetName, request, timeoutMs, signal, metadata);
|
|
144
|
+
async request(channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
145
|
+
return this.outbound.request(channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted);
|
|
146
146
|
}
|
|
147
147
|
tryPublish(channelName, topic, packetName, event, metadata) {
|
|
148
148
|
return this.outbound.tryPublish(channelName, topic, packetName, event, metadata);
|
|
@@ -153,26 +153,26 @@ class ZLinkChannelRuntimeManager {
|
|
|
153
153
|
routeSubmit(routerChannelId, targetNodeRid, packetName, message, metadata) {
|
|
154
154
|
return this.outbound.routeSubmit(routerChannelId, targetNodeRid, packetName, message, metadata);
|
|
155
155
|
}
|
|
156
|
-
async routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata) {
|
|
157
|
-
return this.outbound.routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata);
|
|
156
|
+
async routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
157
|
+
return this.outbound.routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata, onAdmitted);
|
|
158
158
|
}
|
|
159
159
|
async routeSendToSpot(spotRouteTarget, packetName, message, metadata) {
|
|
160
160
|
return this.spotRoutes.routeSendToSpot(spotRouteTarget, packetName, message, metadata);
|
|
161
161
|
}
|
|
162
|
-
async routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata) {
|
|
163
|
-
return this.spotRoutes.routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata);
|
|
162
|
+
async routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
163
|
+
return this.spotRoutes.routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata, onAdmitted);
|
|
164
164
|
}
|
|
165
|
-
async routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal) {
|
|
166
|
-
return this.spotRoutes.routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal);
|
|
165
|
+
async routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal, onAdmitted) {
|
|
166
|
+
return this.spotRoutes.routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal, onAdmitted);
|
|
167
167
|
}
|
|
168
168
|
async routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message, metadata) {
|
|
169
169
|
return this.spotRoutes.routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message, metadata);
|
|
170
170
|
}
|
|
171
|
-
async routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal) {
|
|
172
|
-
return this.spotRoutes.routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal);
|
|
171
|
+
async routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal, onAdmitted) {
|
|
172
|
+
return this.spotRoutes.routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
173
173
|
}
|
|
174
|
-
async routeRequestRawToSpot(spotRouteTarget, request, timeoutMs, signal) {
|
|
175
|
-
return this.spotRoutes.routeRequestRawToSpot(spotRouteTarget, request, timeoutMs, signal);
|
|
174
|
+
async routeRequestRawToSpot(spotRouteTarget, request, timeoutMs, signal, onAdmitted) {
|
|
175
|
+
return this.spotRoutes.routeRequestRawToSpot(spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
176
176
|
}
|
|
177
177
|
canRouteChannel(routerChannelId) {
|
|
178
178
|
return this.spotRoutes.canRouteChannel(routerChannelId);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type ZLinkClientServerServerDescriptor, type ZLinkFanoutPublisherDescriptor } from '../../contracts';
|
|
1
|
+
import { type RoutingId, type ZLinkClientServerServerDescriptor, type ZLinkFanoutPublisherDescriptor } from '../../contracts';
|
|
2
2
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
3
|
import type { ZLinkBackendContext, ZLinkBackendDealerSocket, ZLinkBackendPublisherSocket, ZLinkBackendRouterSocket, ZLinkBackendSocketMonitor, ZLinkBackendSubscriberSocket, ZLinkChannelBackendAdapter, ZLinkMonitoringBackendAdapter } from '../backend/contracts';
|
|
4
4
|
import { type ZLinkFrameworkRegistration } from '../configuration';
|
|
5
5
|
import { ZLinkListenerRecords } from '../foundation/listener-records';
|
|
6
6
|
import { ServiceDiscoveryRegistry } from '../foundation/service-discovery-registry';
|
|
7
|
+
import { ServiceLivenessConnection } from '../foundation/service-liveness-registry';
|
|
7
8
|
import type { ApplicationJobQueue } from '../host/application-job-queue';
|
|
8
9
|
import type { ZLinkChannelEnvelopeHeader } from './channel-envelope';
|
|
9
10
|
export interface ZLinkClientServerServerSocketIdentity {
|
|
@@ -20,6 +21,12 @@ export interface ZLinkFanoutConnectionCallbacks {
|
|
|
20
21
|
readonly onReady: () => void;
|
|
21
22
|
readonly onTerminated: (reason: 'disconnect' | 'deadline' | 'protocol') => void;
|
|
22
23
|
}
|
|
24
|
+
interface ClientServerServerPeer {
|
|
25
|
+
readonly channelName: string;
|
|
26
|
+
readonly routingId: RoutingId;
|
|
27
|
+
readonly normalizedEffectiveMaxMessageBytes: number;
|
|
28
|
+
readonly liveness: ServiceLivenessConnection;
|
|
29
|
+
}
|
|
23
30
|
export declare class ZLinkChannelSocketRegistry {
|
|
24
31
|
private readonly registration;
|
|
25
32
|
private readonly adapter;
|
|
@@ -39,7 +46,6 @@ export declare class ZLinkChannelSocketRegistry {
|
|
|
39
46
|
private readonly clientServerServerDescriptors;
|
|
40
47
|
private readonly clientServerPublicWeights;
|
|
41
48
|
private readonly routeMeshPublicWeights;
|
|
42
|
-
private readonly clientServerAdmittedClients;
|
|
43
49
|
private readonly clientServerServerPeers;
|
|
44
50
|
private readonly disposal;
|
|
45
51
|
private readonly ownedResources;
|
|
@@ -83,11 +89,12 @@ export declare class ZLinkChannelSocketRegistry {
|
|
|
83
89
|
removeFanoutPublisher(descriptor: ZLinkFanoutPublisherDescriptor, connectionId: string): boolean;
|
|
84
90
|
setClientServerServerDescriptor(descriptor: ZLinkClientServerServerDescriptor | undefined, channelName: string): void;
|
|
85
91
|
private notifyClientServerTopology;
|
|
92
|
+
clientServerServerPeersForChannel(channelName: string): Map<RoutingId, ClientServerServerPeer>;
|
|
86
93
|
tryHandleClientServerControl(channelName: string, received: {
|
|
87
94
|
readonly parts: readonly Message[];
|
|
88
95
|
readonly replyToken: unknown | null;
|
|
89
96
|
readonly routingId: unknown;
|
|
90
|
-
}, router: ZLinkBackendRouterSocket): boolean;
|
|
97
|
+
}, router: ZLinkBackendRouterSocket, peers?: Map<string, ClientServerServerPeer>): boolean;
|
|
91
98
|
tickClientServerLiveness(nowMs?: number): void;
|
|
92
99
|
openFanoutSubscriberConnection(channelName: string, connectionId: string, endpoint: string, callbacks: ZLinkFanoutConnectionCallbacks): ZLinkBackendSubscriberSocket;
|
|
93
100
|
closeFanoutSubscriberConnection(connectionId: string): Promise<void>;
|