@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
|
@@ -36,6 +36,7 @@ export type SubmitResult = (typeof SubmitResult)[keyof typeof SubmitResult];
|
|
|
36
36
|
export type ZLinkBackendSendFlags = number;
|
|
37
37
|
export type ZLinkBackendRecvFlags = number;
|
|
38
38
|
export declare const ZLINK_BACKEND_SEND_NONE: ZLinkBackendSendFlags;
|
|
39
|
+
export declare const ZLINK_BACKEND_SEND_DONT_WAIT: ZLinkBackendSendFlags;
|
|
39
40
|
export declare const ZLINK_BACKEND_RECV_DONT_WAIT: ZLinkBackendRecvFlags;
|
|
40
41
|
export declare class ZLinkBackendResultError extends Error {
|
|
41
42
|
readonly operation: 'request' | 'submit';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZLinkBackendResultError = exports.ZLINK_BACKEND_RECV_DONT_WAIT = exports.ZLINK_BACKEND_SEND_NONE = exports.SubmitResult = exports.RequestResult = void 0;
|
|
3
|
+
exports.ZLinkBackendResultError = exports.ZLINK_BACKEND_RECV_DONT_WAIT = exports.ZLINK_BACKEND_SEND_DONT_WAIT = exports.ZLINK_BACKEND_SEND_NONE = exports.SubmitResult = exports.RequestResult = void 0;
|
|
4
4
|
exports.isZLinkBackendResultError = isZLinkBackendResultError;
|
|
5
5
|
exports.isBackendNotConnectedError = isBackendNotConnectedError;
|
|
6
6
|
exports.isBackendRequestTimeoutError = isBackendRequestTimeoutError;
|
|
@@ -37,6 +37,7 @@ exports.SubmitResult = Object.freeze({
|
|
|
37
37
|
NotAdmitted: 13
|
|
38
38
|
});
|
|
39
39
|
exports.ZLINK_BACKEND_SEND_NONE = 0;
|
|
40
|
+
exports.ZLINK_BACKEND_SEND_DONT_WAIT = 1;
|
|
40
41
|
exports.ZLINK_BACKEND_RECV_DONT_WAIT = 1;
|
|
41
42
|
class ZLinkBackendResultError extends Error {
|
|
42
43
|
operation;
|
|
@@ -35,6 +35,7 @@ export declare class DefaultZLinkRouteClient implements ZLinkRouteClient {
|
|
|
35
35
|
private readonly transport?;
|
|
36
36
|
private readonly spotRouterChannelIdForMesh;
|
|
37
37
|
private readonly channelTransport?;
|
|
38
|
+
private readonly nodeSends;
|
|
38
39
|
constructor(registration: ZLinkFrameworkRegistration, transport?: ZLinkRouteClientTransport | undefined, spotRouterChannelIdForMesh?: (meshName: string) => string, channelTransport?: ZLinkChannelClientTransportSource | undefined);
|
|
39
40
|
sendToNode(meshName: string, targetNodeRid: string, message: unknown): ZLinkSendCall;
|
|
40
41
|
requestToNode(meshName: string, targetNodeRid: string, request: unknown): ZLinkRequestCall;
|
|
@@ -4,6 +4,7 @@ exports.DefaultZLinkSpotPublisherClient = exports.DefaultZLinkRouteClient = expo
|
|
|
4
4
|
exports.resolveChannelRoute = resolveChannelRoute;
|
|
5
5
|
exports.requireUniqueRouteMeshChannel = requireUniqueRouteMeshChannel;
|
|
6
6
|
const Registration_1 = require("../../contracts/Configuration/Registration");
|
|
7
|
+
const request_result_1 = require("../messaging/request-result");
|
|
7
8
|
const configuration_1 = require("../configuration");
|
|
8
9
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
9
10
|
const submission_result_1 = require("../messaging/submission-result");
|
|
@@ -79,6 +80,7 @@ class DefaultZLinkRouteClient {
|
|
|
79
80
|
transport;
|
|
80
81
|
spotRouterChannelIdForMesh;
|
|
81
82
|
channelTransport;
|
|
83
|
+
nodeSends = new Map();
|
|
82
84
|
constructor(registration, transport, spotRouterChannelIdForMesh = (meshName) => meshName, channelTransport) {
|
|
83
85
|
this.registration = registration;
|
|
84
86
|
this.transport = transport;
|
|
@@ -86,10 +88,23 @@ class DefaultZLinkRouteClient {
|
|
|
86
88
|
this.channelTransport = channelTransport;
|
|
87
89
|
}
|
|
88
90
|
sendToNode(meshName, targetNodeRid, message) {
|
|
89
|
-
|
|
91
|
+
let targets = this.nodeSends.get(meshName);
|
|
92
|
+
if (targets === undefined)
|
|
93
|
+
this.nodeSends.set(meshName, (targets = new Map()));
|
|
94
|
+
let prepared = targets.get(targetNodeRid);
|
|
95
|
+
if (prepared === undefined) {
|
|
96
|
+
prepared = {
|
|
97
|
+
validate: () => {
|
|
98
|
+
this.requireMesh(meshName);
|
|
99
|
+
},
|
|
100
|
+
submit: (packetName, metadata, payload) => normalizeSubmitResult(this.requireTransport().submit(meshName, targetNodeRid, packetName, payload, metadata))
|
|
101
|
+
};
|
|
102
|
+
targets.set(targetNodeRid, prepared);
|
|
103
|
+
}
|
|
104
|
+
return new DefaultZLinkSendCall(prepared.validate, prepared.submit, message);
|
|
90
105
|
}
|
|
91
106
|
requestToNode(meshName, targetNodeRid, request) {
|
|
92
|
-
return new DefaultZLinkRequestCall(() => this.requireMesh(meshName), (packetName, timeoutMs, metadata, signal) => this.requireTransport().request(meshName, targetNodeRid, packetName, request, timeoutMs, signal, metadata), this.defaultRequestTimeout(meshName));
|
|
107
|
+
return new DefaultZLinkRequestCall(() => this.requireMesh(meshName), (packetName, timeoutMs, metadata, signal, onAdmitted) => this.requireTransport().request(meshName, targetNodeRid, packetName, request, timeoutMs, signal, metadata, onAdmitted), this.defaultRequestTimeout(meshName));
|
|
93
108
|
}
|
|
94
109
|
sendToChannel(channelName, message) {
|
|
95
110
|
return new DefaultZLinkSendCall(() => this.requireChannelRoute(channelName), async (packetName, metadata) => {
|
|
@@ -101,12 +116,12 @@ class DefaultZLinkRouteClient {
|
|
|
101
116
|
});
|
|
102
117
|
}
|
|
103
118
|
requestToChannel(channelName, request) {
|
|
104
|
-
return new DefaultZLinkRequestCall(() => this.requireChannelRoute(channelName), (packetName, timeoutMs, metadata, signal) => {
|
|
119
|
+
return new DefaultZLinkRequestCall(() => this.requireChannelRoute(channelName), (packetName, timeoutMs, metadata, signal, onAdmitted) => {
|
|
105
120
|
const route = this.requireChannelRoute(channelName);
|
|
106
121
|
if (route.kind === 'route-mesh') {
|
|
107
|
-
return this.requireTransport().requestToChannel(route.meshName, channelName, packetName, request, timeoutMs, signal, metadata);
|
|
122
|
+
return this.requireTransport().requestToChannel(route.meshName, channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted);
|
|
108
123
|
}
|
|
109
|
-
return this.requireChannelTransport().request(channelName, packetName, request, timeoutMs, signal, metadata);
|
|
124
|
+
return this.requireChannelTransport().request(channelName, packetName, request, timeoutMs, signal, metadata, onAdmitted);
|
|
110
125
|
}, this.defaultRequestTimeoutForChannel(channelName));
|
|
111
126
|
}
|
|
112
127
|
sendToSpot(spot, message) {
|
|
@@ -123,10 +138,11 @@ class DefaultZLinkRouteClient {
|
|
|
123
138
|
requestToSpot(spot, request) {
|
|
124
139
|
return new DefaultZLinkRequestCall(() => {
|
|
125
140
|
this.requireSpotTransport();
|
|
126
|
-
}, (_packetName, timeoutMs, metadata, signal) => (0, spot_outbound_1.requestToSpotHandle)(this.requireSpotTransport(), spot, request, {
|
|
141
|
+
}, (_packetName, timeoutMs, metadata, signal, onAdmitted) => (0, spot_outbound_1.requestToSpotHandle)(this.requireSpotTransport(), spot, request, {
|
|
127
142
|
timeoutMs,
|
|
128
143
|
signal,
|
|
129
144
|
metadata,
|
|
145
|
+
onAdmitted,
|
|
130
146
|
spotRouterChannelIdForMesh: this.spotRouterChannelIdForMesh
|
|
131
147
|
}), this.registration.requestTimeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS);
|
|
132
148
|
}
|
|
@@ -217,14 +233,17 @@ exports.DefaultZLinkSpotPublisherClient = DefaultZLinkSpotPublisherClient;
|
|
|
217
233
|
class DefaultZLinkSendCall {
|
|
218
234
|
validate;
|
|
219
235
|
submitter;
|
|
220
|
-
|
|
236
|
+
message;
|
|
237
|
+
selectedMetadata;
|
|
221
238
|
executed = false;
|
|
222
|
-
constructor(validate, submitter) {
|
|
239
|
+
constructor(validate, submitter, message) {
|
|
223
240
|
this.validate = validate;
|
|
224
241
|
this.submitter = submitter;
|
|
242
|
+
this.message = message;
|
|
225
243
|
}
|
|
226
244
|
metadata(keyOrMetadata, value) {
|
|
227
245
|
ensureNotExecuted(this.executed);
|
|
246
|
+
this.selectedMetadata ??= new Map();
|
|
228
247
|
if (typeof keyOrMetadata === 'string') {
|
|
229
248
|
this.selectedMetadata.set(keyOrMetadata, value);
|
|
230
249
|
}
|
|
@@ -235,12 +254,20 @@ class DefaultZLinkSendCall {
|
|
|
235
254
|
}
|
|
236
255
|
return this;
|
|
237
256
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
257
|
+
submit() {
|
|
258
|
+
try {
|
|
259
|
+
ensureNotExecuted(this.executed);
|
|
260
|
+
this.validate();
|
|
261
|
+
this.executed = true;
|
|
262
|
+
const result = this.submitter(undefined, this.selectedMetadata ?? EMPTY_CALL_METADATA, this.message);
|
|
263
|
+
if (result instanceof Promise)
|
|
264
|
+
return result.then(completeOneWaySend);
|
|
265
|
+
completeOneWaySend(result);
|
|
266
|
+
return completedOneWaySend;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
return Promise.reject(error);
|
|
270
|
+
}
|
|
244
271
|
}
|
|
245
272
|
}
|
|
246
273
|
function ensureNotExecuted(executed) {
|
|
@@ -248,15 +275,22 @@ function ensureNotExecuted(executed) {
|
|
|
248
275
|
(0, submission_result_1.throwAlreadySubmitted)('ZLink call');
|
|
249
276
|
}
|
|
250
277
|
}
|
|
278
|
+
const EMPTY_CALL_METADATA = new Map();
|
|
279
|
+
const completedOneWaySend = Promise.resolve();
|
|
280
|
+
function completeOneWaySend(result) {
|
|
281
|
+
(0, submission_result_1.requireOneWayCompletion)(result, 'One-way send');
|
|
282
|
+
}
|
|
251
283
|
function normalizeSubmitResult(result) {
|
|
252
|
-
return result
|
|
284
|
+
return result instanceof Promise
|
|
285
|
+
? result.then((value) => value ?? submission_result_1.submittedResult)
|
|
286
|
+
: (result ?? submission_result_1.submittedResult);
|
|
253
287
|
}
|
|
254
288
|
class DefaultZLinkRequestCall {
|
|
255
289
|
validate;
|
|
256
290
|
submitter;
|
|
257
291
|
defaultRequestTimeoutMs;
|
|
258
292
|
timeoutMs;
|
|
259
|
-
selectedMetadata
|
|
293
|
+
selectedMetadata;
|
|
260
294
|
turn = (0, execution_1.captureZLinkSpotSerialTurn)();
|
|
261
295
|
constructor(validate, submitter, defaultRequestTimeoutMs) {
|
|
262
296
|
this.validate = validate;
|
|
@@ -264,6 +298,7 @@ class DefaultZLinkRequestCall {
|
|
|
264
298
|
this.defaultRequestTimeoutMs = defaultRequestTimeoutMs;
|
|
265
299
|
}
|
|
266
300
|
metadata(keyOrMetadata, value) {
|
|
301
|
+
this.selectedMetadata ??= new Map();
|
|
267
302
|
if (typeof keyOrMetadata === 'string') {
|
|
268
303
|
this.selectedMetadata.set(keyOrMetadata, value);
|
|
269
304
|
}
|
|
@@ -278,16 +313,18 @@ class DefaultZLinkRequestCall {
|
|
|
278
313
|
this.timeoutMs = timeoutMs;
|
|
279
314
|
return this;
|
|
280
315
|
}
|
|
281
|
-
|
|
282
|
-
(0,
|
|
283
|
-
|
|
284
|
-
|
|
316
|
+
submit(signal) {
|
|
317
|
+
return (0, request_result_1.createZLinkRequest)((onAdmitted) => {
|
|
318
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
319
|
+
this.validate();
|
|
320
|
+
return this.submitter(undefined, this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata === undefined ? EMPTY_CALL_METADATA : new Map(this.selectedMetadata), signal, onAdmitted);
|
|
321
|
+
});
|
|
285
322
|
}
|
|
286
323
|
async yield(signal) {
|
|
287
324
|
const turn = (0, execution_1.requireZLinkYieldTurn)(this.turn);
|
|
288
325
|
(0, abort_1.throwIfAborted)(signal);
|
|
289
326
|
this.validate();
|
|
290
|
-
const pending = this.submitter(undefined, this.timeoutMs ?? this.defaultRequestTimeoutMs, new Map(this.selectedMetadata), signal);
|
|
327
|
+
const pending = this.submitter(undefined, this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata === undefined ? EMPTY_CALL_METADATA : new Map(this.selectedMetadata), signal);
|
|
291
328
|
return turn.yieldPromise(pending);
|
|
292
329
|
}
|
|
293
330
|
}
|
|
@@ -39,8 +39,8 @@ interface ZLinkRequestDispatch<TContext extends ZLinkMessageContext> {
|
|
|
39
39
|
readonly context: TContext;
|
|
40
40
|
readonly signal?: AbortSignal;
|
|
41
41
|
readonly missingHandlerMessage: string;
|
|
42
|
-
readonly writeReply: (reply: unknown) => Promise<void>;
|
|
43
|
-
readonly writeError: (error: unknown) => Promise<void>;
|
|
42
|
+
readonly writeReply: (reply: unknown) => void | Promise<void>;
|
|
43
|
+
readonly writeError: (error: unknown) => void | Promise<void>;
|
|
44
44
|
}
|
|
45
45
|
export declare class ZLinkChannelDispatchPipeline {
|
|
46
46
|
private readonly options;
|
|
@@ -66,6 +66,7 @@ export declare class ZLinkChannelDispatchPipeline {
|
|
|
66
66
|
readonly writeProtocolError?: (error: ZLinkFrameworkException) => Promise<void>;
|
|
67
67
|
}): Promise<void>;
|
|
68
68
|
private invoke;
|
|
69
|
+
private invokeFiltered;
|
|
69
70
|
private createFilterContext;
|
|
70
71
|
private dispatchKind;
|
|
71
72
|
private report;
|
|
@@ -30,8 +30,10 @@ class ZLinkChannelDispatchPipeline {
|
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
32
|
const flow = (0, flow_context_1.createInboundFlow)(dispatch.fields.flowId, dispatch.fields.flowOrigin, this.options.dispatchErrors.flow.flowCreationEnabled(), undefined);
|
|
33
|
-
const invocation = await (
|
|
34
|
-
|
|
33
|
+
const invocation = await (flow === undefined
|
|
34
|
+
? this.invoke(dispatch.envelope, dispatch.codecs, dispatch.handler, dispatch.context, dispatch.fields, dispatch.signal)
|
|
35
|
+
: (0, flow_context_1.runWithFlow)(flow, () => this.invoke(dispatch.envelope, dispatch.codecs, dispatch.handler, dispatch.context, dispatch.fields, dispatch.signal)));
|
|
36
|
+
if (invocation !== HANDLER_FILTER_REJECTED) {
|
|
35
37
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Completed, dispatch.fields);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -58,11 +60,13 @@ class ZLinkChannelDispatchPipeline {
|
|
|
58
60
|
let reply;
|
|
59
61
|
try {
|
|
60
62
|
const flow = (0, flow_context_1.createInboundFlow)(dispatch.fields.flowId, dispatch.fields.flowOrigin, this.options.dispatchErrors.flow.flowCreationEnabled(), undefined);
|
|
61
|
-
const invocation = await (
|
|
62
|
-
|
|
63
|
+
const invocation = await (flow === undefined
|
|
64
|
+
? this.invoke(dispatch.envelope, dispatch.codecs, dispatch.handler, dispatch.context, dispatch.fields, dispatch.signal)
|
|
65
|
+
: (0, flow_context_1.runWithFlow)(flow, () => this.invoke(dispatch.envelope, dispatch.codecs, dispatch.handler, dispatch.context, dispatch.fields, dispatch.signal)));
|
|
66
|
+
if (invocation === HANDLER_FILTER_REJECTED) {
|
|
63
67
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `A handler filter rejected '${this.options.channelName}:${dispatch.fields.packetName}'.`);
|
|
64
68
|
}
|
|
65
|
-
reply = invocation
|
|
69
|
+
reply = invocation;
|
|
66
70
|
}
|
|
67
71
|
catch (error) {
|
|
68
72
|
try {
|
|
@@ -78,7 +82,9 @@ class ZLinkChannelDispatchPipeline {
|
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
84
|
try {
|
|
81
|
-
|
|
85
|
+
const written = dispatch.writeReply(reply);
|
|
86
|
+
if (written !== undefined)
|
|
87
|
+
await written;
|
|
82
88
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, dispatch.fields);
|
|
83
89
|
}
|
|
84
90
|
catch (error) {
|
|
@@ -99,8 +105,7 @@ class ZLinkChannelDispatchPipeline {
|
|
|
99
105
|
*/
|
|
100
106
|
async dispatchMalformed(input) {
|
|
101
107
|
const { info } = input;
|
|
102
|
-
const isRequest =
|
|
103
|
-
(info.kind === undefined && input.transportRequest);
|
|
108
|
+
const isRequest = input.transportRequest;
|
|
104
109
|
let replied = false;
|
|
105
110
|
if (isRequest && input.writeProtocolError !== undefined && info.correlationId !== undefined) {
|
|
106
111
|
const protocolError = new contracts_1.ZLinkFrameworkException(contracts_1.ZLinkFrameworkErrorKind.ProtocolError, `Channel '${this.options.channelName}' received a malformed envelope.`);
|
|
@@ -126,15 +131,18 @@ class ZLinkChannelDispatchPipeline {
|
|
|
126
131
|
error: input.error
|
|
127
132
|
});
|
|
128
133
|
}
|
|
129
|
-
|
|
134
|
+
invoke(envelope, codecs, handler, context, fields, signal) {
|
|
130
135
|
(0, application_job_queue_scope_1.releaseApplicationJobPermitBeforeHandler)();
|
|
131
136
|
if (this.filters.length === 0) {
|
|
132
137
|
// Fast path for the dominant unfiltered dispatch: skip the filter
|
|
133
138
|
// context object and chain machinery entirely.
|
|
134
139
|
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs);
|
|
135
140
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, fields);
|
|
136
|
-
return
|
|
141
|
+
return handler.handle(payload, context);
|
|
137
142
|
}
|
|
143
|
+
return this.invokeFiltered(envelope, codecs, handler, context, fields, signal);
|
|
144
|
+
}
|
|
145
|
+
async invokeFiltered(envelope, codecs, handler, context, fields, signal) {
|
|
138
146
|
let value;
|
|
139
147
|
const handlerInvoked = await (0, handlers_1.invokeZLinkHandlerFilters)(this.filters, this.createFilterContext(context, fields), async () => {
|
|
140
148
|
// Filters are the channel admission gate. Decode only after they have
|
|
@@ -143,7 +151,7 @@ class ZLinkChannelDispatchPipeline {
|
|
|
143
151
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, fields);
|
|
144
152
|
value = await handler.handle(payload, context);
|
|
145
153
|
}, signal);
|
|
146
|
-
return
|
|
154
|
+
return handlerInvoked ? value : HANDLER_FILTER_REJECTED;
|
|
147
155
|
}
|
|
148
156
|
createFilterContext(context, fields) {
|
|
149
157
|
const dispatchKind = this.dispatchKind(context, fields);
|
|
@@ -222,6 +230,7 @@ class ZLinkChannelDispatchPipeline {
|
|
|
222
230
|
}
|
|
223
231
|
}
|
|
224
232
|
exports.ZLinkChannelDispatchPipeline = ZLinkChannelDispatchPipeline;
|
|
233
|
+
const HANDLER_FILTER_REJECTED = Symbol('handler-filter-rejected');
|
|
225
234
|
const DEFAULT_UNHANDLED_DISPATCH = {
|
|
226
235
|
request: contracts_1.ZLinkUnhandledDispatchAction.ReplyError,
|
|
227
236
|
send: contracts_1.ZLinkUnhandledDispatchAction.LogAndDrop,
|
|
@@ -43,6 +43,7 @@ export declare class ZLinkChannelDispatchServices {
|
|
|
43
43
|
channelSendHandler(handlerType: Type): ZLinkChannelSendHandler;
|
|
44
44
|
routeRequestHandler(handlerType: Type): ZLinkRouteRuntimeRequestHandler;
|
|
45
45
|
routeSendHandler(handlerType: Type): ZLinkRouteRuntimeSendHandler;
|
|
46
|
+
private invokeScopeFreeHandler;
|
|
46
47
|
private invokeHandlerFilters;
|
|
47
48
|
private withHandlerScope;
|
|
48
49
|
beginOutbound(outcome: ZLinkMessageFlowOutcome, result?: ZLinkRuntimeMessageFlowResult): ZLinkChannelOutboundTracePoint | undefined;
|
|
@@ -48,6 +48,13 @@ class ZLinkChannelDispatchServices {
|
|
|
48
48
|
return this.handlerFiltersValue;
|
|
49
49
|
}
|
|
50
50
|
channelRequestHandler(handlerType) {
|
|
51
|
+
const activate = this.registration.filterTypes.length === 0
|
|
52
|
+
? (0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType)
|
|
53
|
+
: undefined;
|
|
54
|
+
if (activate !== undefined)
|
|
55
|
+
return {
|
|
56
|
+
handle: (payload, context) => this.invokeScopeFreeHandler(activate, payload, context)
|
|
57
|
+
};
|
|
51
58
|
return {
|
|
52
59
|
handle: (payload, context) => this.withHandlerScope(context, async (scope) => {
|
|
53
60
|
const handler = await scope.resolve(handlerType);
|
|
@@ -56,6 +63,13 @@ class ZLinkChannelDispatchServices {
|
|
|
56
63
|
};
|
|
57
64
|
}
|
|
58
65
|
channelSendHandler(handlerType) {
|
|
66
|
+
const activate = this.registration.filterTypes.length === 0
|
|
67
|
+
? (0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType)
|
|
68
|
+
: undefined;
|
|
69
|
+
if (activate !== undefined)
|
|
70
|
+
return {
|
|
71
|
+
handle: (payload, context) => this.invokeScopeFreeHandler(activate, payload, context)
|
|
72
|
+
};
|
|
59
73
|
return {
|
|
60
74
|
handle: (payload, context) => this.withHandlerScope(context, async (scope) => {
|
|
61
75
|
const handler = await scope.resolve(handlerType);
|
|
@@ -64,6 +78,13 @@ class ZLinkChannelDispatchServices {
|
|
|
64
78
|
};
|
|
65
79
|
}
|
|
66
80
|
routeRequestHandler(handlerType) {
|
|
81
|
+
const activate = this.registration.filterTypes.length === 0
|
|
82
|
+
? (0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType)
|
|
83
|
+
: undefined;
|
|
84
|
+
if (activate !== undefined)
|
|
85
|
+
return {
|
|
86
|
+
handle: (payload, context) => this.invokeScopeFreeHandler(activate, payload, context)
|
|
87
|
+
};
|
|
67
88
|
return {
|
|
68
89
|
handle: (payload, context) => this.withHandlerScope(context, async (scope) => {
|
|
69
90
|
const handler = await scope.resolve(handlerType);
|
|
@@ -72,6 +93,13 @@ class ZLinkChannelDispatchServices {
|
|
|
72
93
|
};
|
|
73
94
|
}
|
|
74
95
|
routeSendHandler(handlerType) {
|
|
96
|
+
const activate = this.registration.filterTypes.length === 0
|
|
97
|
+
? (0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType)
|
|
98
|
+
: undefined;
|
|
99
|
+
if (activate !== undefined)
|
|
100
|
+
return {
|
|
101
|
+
handle: (payload, context) => this.invokeScopeFreeHandler(activate, payload, context)
|
|
102
|
+
};
|
|
75
103
|
return {
|
|
76
104
|
handle: (payload, context) => this.withHandlerScope(context, async (scope) => {
|
|
77
105
|
const handler = await scope.resolve(handlerType);
|
|
@@ -79,6 +107,23 @@ class ZLinkChannelDispatchServices {
|
|
|
79
107
|
})
|
|
80
108
|
};
|
|
81
109
|
}
|
|
110
|
+
invokeScopeFreeHandler(activate, payload, context) {
|
|
111
|
+
const handler = activate();
|
|
112
|
+
const cleanup = (0, handler_instance_scope_1.handlerInstanceCleanup)(handler);
|
|
113
|
+
if (cleanup === undefined)
|
|
114
|
+
return handler.handle(payload, context);
|
|
115
|
+
let result;
|
|
116
|
+
try {
|
|
117
|
+
result = handler.handle(payload, context);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const disposed = cleanup.call(handler);
|
|
121
|
+
return Promise.resolve(disposed).then(() => {
|
|
122
|
+
throw error;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return Promise.resolve(result).finally(() => cleanup.call(handler));
|
|
126
|
+
}
|
|
82
127
|
async invokeHandlerFilters(context, next, signal) {
|
|
83
128
|
const scoped = (0, handler_filter_scope_1.handlerFilterScope)(this.providerResolver);
|
|
84
129
|
if (scoped !== undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoutingId, ZLinkMessageContext, ZLinkHandlerFilter, ZLinkPublishMessageContext, ZLinkRouteMessageContext, ZLinkUnhandledDispatchOptions } from '../../contracts';
|
|
2
2
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
|
-
import type
|
|
3
|
+
import { type ReceiveRecord } from '../foundation/service-runtime-contracts';
|
|
4
4
|
import { type ZLinkRouteChannelOptions } from '../configuration';
|
|
5
5
|
import type { ZLinkBackendSpotRouteBridge } from '../backend/contracts';
|
|
6
6
|
import type { ZLinkRuntimeMetrics } from '../diagnostics';
|
|
@@ -5,12 +5,14 @@ exports.collectRouteChannelHandlers = collectRouteChannelHandlers;
|
|
|
5
5
|
const contracts_1 = require("../../contracts");
|
|
6
6
|
const ZLinkDispatchOptions_1 = require("../../contracts/Dispatch/ZLinkDispatchOptions");
|
|
7
7
|
const runtime_values_1 = require("../backend/runtime-values");
|
|
8
|
+
const service_runtime_contracts_1 = require("../foundation/service-runtime-contracts");
|
|
8
9
|
const configuration_1 = require("../configuration");
|
|
9
10
|
const channel_envelope_1 = require("./channel-envelope");
|
|
10
11
|
const channel_envelope_inspection_1 = require("./channel-envelope-inspection");
|
|
11
12
|
const channel_multipart_1 = require("./channel-multipart");
|
|
12
13
|
const channel_framework_packets_1 = require("./channel-framework-packets");
|
|
13
14
|
const channel_dispatch_pipeline_1 = require("./channel-dispatch-pipeline");
|
|
15
|
+
const completedChannelReply = Promise.resolve();
|
|
14
16
|
class ZLinkChannelRequestDispatcher {
|
|
15
17
|
options;
|
|
16
18
|
pipeline;
|
|
@@ -49,7 +51,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
49
51
|
await this.pipeline.dispatchMalformed({
|
|
50
52
|
info,
|
|
51
53
|
error,
|
|
52
|
-
transportRequest: replyToken
|
|
54
|
+
transportRequest: replyToken != null,
|
|
53
55
|
writeProtocolError: replyToken === null
|
|
54
56
|
? undefined
|
|
55
57
|
: (protocolError) => this.submitReply((0, channel_multipart_1.appendParts)(router.reply(received.routingId, replyToken), (0, channel_envelope_1.encodeChannelErrorReplyParts)((0, channel_envelope_inspection_1.malformedProtocolErrorRequestHeader)(this.options.channelName, info), protocolError)), signal)
|
|
@@ -124,9 +126,9 @@ class ZLinkChannelRequestDispatcher {
|
|
|
124
126
|
writeError: (error) => this.submitReply((0, channel_multipart_1.appendParts)(router.reply(received.routingId, replyToken), (0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error)), signal)
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
dispatchMesh(record, signal) {
|
|
128
130
|
if (record.parts.length === 0 || record.parts[0].data().length === 0) {
|
|
129
|
-
return;
|
|
131
|
+
return completedChannelReply;
|
|
130
132
|
}
|
|
131
133
|
let envelope;
|
|
132
134
|
try {
|
|
@@ -134,16 +136,15 @@ class ZLinkChannelRequestDispatcher {
|
|
|
134
136
|
}
|
|
135
137
|
catch (error) {
|
|
136
138
|
const info = (0, channel_envelope_inspection_1.inspectMalformedChannelHeader)(record.parts, this.flowEnabled());
|
|
137
|
-
|
|
139
|
+
return this.pipeline.dispatchMalformed({
|
|
138
140
|
info,
|
|
139
141
|
error,
|
|
140
|
-
transportRequest:
|
|
142
|
+
transportRequest: isMeshRequest(record),
|
|
141
143
|
sourceRid: record.sourceNodeRid == null ? undefined : String(record.sourceNodeRid),
|
|
142
144
|
writeProtocolError: async (protocolError) => {
|
|
143
145
|
requireMeshReplyAccepted(record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)((0, channel_envelope_inspection_1.malformedProtocolErrorRequestHeader)(this.options.channelName, info), protocolError)));
|
|
144
146
|
}
|
|
145
147
|
});
|
|
146
|
-
return;
|
|
147
148
|
}
|
|
148
149
|
const packetName = envelope.packetName;
|
|
149
150
|
if (packetName === undefined) {
|
|
@@ -151,7 +152,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
151
152
|
}
|
|
152
153
|
const correlationId = envelope.header.correlationId ?? undefined;
|
|
153
154
|
if (envelope.header.kind === 3 /* ZLinkChannelMessageKind.Command */) {
|
|
154
|
-
|
|
155
|
+
return this.pipeline.dispatchOneWay({
|
|
155
156
|
fields: {
|
|
156
157
|
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Send,
|
|
157
158
|
packetName,
|
|
@@ -165,10 +166,9 @@ class ZLinkChannelRequestDispatcher {
|
|
|
165
166
|
context: this.createMeshContext(envelope, record.sourceNodeRid),
|
|
166
167
|
signal
|
|
167
168
|
});
|
|
168
|
-
return;
|
|
169
169
|
}
|
|
170
170
|
if (envelope.header.kind !== 1 /* ZLinkChannelMessageKind.Request */) {
|
|
171
|
-
return;
|
|
171
|
+
return completedChannelReply;
|
|
172
172
|
}
|
|
173
173
|
const fields = {
|
|
174
174
|
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Request,
|
|
@@ -177,7 +177,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
177
177
|
flowId: envelope.header.flowId,
|
|
178
178
|
flowOrigin: envelope.header.flowOrigin
|
|
179
179
|
};
|
|
180
|
-
|
|
180
|
+
return this.pipeline.dispatchRequest({
|
|
181
181
|
fields,
|
|
182
182
|
envelope,
|
|
183
183
|
codecs: this.options.codecs,
|
|
@@ -185,10 +185,10 @@ class ZLinkChannelRequestDispatcher {
|
|
|
185
185
|
context: this.createMeshContext(envelope, record.sourceNodeRid),
|
|
186
186
|
signal,
|
|
187
187
|
missingHandlerMessage: `No channel request handler is registered for '${this.options.channelName}:${packetName}'.`,
|
|
188
|
-
writeReply:
|
|
188
|
+
writeReply: (reply) => {
|
|
189
189
|
requireMeshReplyAccepted(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, reply, this.options.codecs)));
|
|
190
190
|
},
|
|
191
|
-
writeError:
|
|
191
|
+
writeError: (error) => {
|
|
192
192
|
requireMeshReplyAccepted(record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error)));
|
|
193
193
|
}
|
|
194
194
|
});
|
|
@@ -198,7 +198,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
198
198
|
if (operation.submit() === false) {
|
|
199
199
|
throw new configuration_1.ZLinkConfigurationException('Channel reply was not accepted by Core.');
|
|
200
200
|
}
|
|
201
|
-
return
|
|
201
|
+
return completedChannelReply;
|
|
202
202
|
}
|
|
203
203
|
createMeshContext(envelope, sourceNodeRid) {
|
|
204
204
|
const base = {
|
|
@@ -381,7 +381,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
381
381
|
await this.pipeline.dispatchMalformed({
|
|
382
382
|
info,
|
|
383
383
|
error,
|
|
384
|
-
transportRequest: replyToken
|
|
384
|
+
transportRequest: replyToken != null,
|
|
385
385
|
sourceRid: String(received.routingId),
|
|
386
386
|
writeProtocolError: replyToken === null
|
|
387
387
|
? undefined
|
|
@@ -452,9 +452,9 @@ class ZLinkRoutePacketDispatcher {
|
|
|
452
452
|
writeError: (error) => this.submitReply((0, channel_multipart_1.appendParts)(router.reply(received.routingId, replyToken), (0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error)))
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
|
-
|
|
455
|
+
dispatchMesh(record, signal) {
|
|
456
456
|
if (record.parts.length === 0 || record.parts[0].data().length === 0) {
|
|
457
|
-
return;
|
|
457
|
+
return completedChannelReply;
|
|
458
458
|
}
|
|
459
459
|
let envelope;
|
|
460
460
|
try {
|
|
@@ -462,16 +462,15 @@ class ZLinkRoutePacketDispatcher {
|
|
|
462
462
|
}
|
|
463
463
|
catch (error) {
|
|
464
464
|
const info = (0, channel_envelope_inspection_1.inspectMalformedChannelHeader)(record.parts, this.flowEnabled());
|
|
465
|
-
|
|
465
|
+
return this.pipeline.dispatchMalformed({
|
|
466
466
|
info,
|
|
467
467
|
error,
|
|
468
|
-
transportRequest:
|
|
468
|
+
transportRequest: isMeshRequest(record),
|
|
469
469
|
sourceRid: record.sourceNodeRid == null ? undefined : String(record.sourceNodeRid),
|
|
470
470
|
writeProtocolError: async (protocolError) => {
|
|
471
471
|
requireMeshReplyAccepted(record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)((0, channel_envelope_inspection_1.malformedProtocolErrorRequestHeader)(this.routerChannelId, info), protocolError)));
|
|
472
472
|
}
|
|
473
473
|
});
|
|
474
|
-
return;
|
|
475
474
|
}
|
|
476
475
|
const packetName = envelope.packetName;
|
|
477
476
|
if (packetName === undefined) {
|
|
@@ -480,11 +479,10 @@ class ZLinkRoutePacketDispatcher {
|
|
|
480
479
|
const sourceNodeRid = String(record.sourceNodeRid ?? '');
|
|
481
480
|
const correlationId = envelope.header.correlationId ?? undefined;
|
|
482
481
|
if (envelope.header.kind === 3 /* ZLinkChannelMessageKind.Command */) {
|
|
483
|
-
|
|
484
|
-
return;
|
|
482
|
+
return this.dispatchMeshCommand(envelope, packetName, sourceNodeRid, record.sourceNodeRid, signal);
|
|
485
483
|
}
|
|
486
484
|
if (envelope.header.kind !== 1 /* ZLinkChannelMessageKind.Request */) {
|
|
487
|
-
return;
|
|
485
|
+
return completedChannelReply;
|
|
488
486
|
}
|
|
489
487
|
const fields = {
|
|
490
488
|
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Request,
|
|
@@ -495,7 +493,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
495
493
|
flowOrigin: envelope.header.flowOrigin
|
|
496
494
|
};
|
|
497
495
|
const codecs = (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs);
|
|
498
|
-
|
|
496
|
+
return this.pipeline.dispatchRequest({
|
|
499
497
|
fields,
|
|
500
498
|
envelope,
|
|
501
499
|
codecs,
|
|
@@ -503,10 +501,10 @@ class ZLinkRoutePacketDispatcher {
|
|
|
503
501
|
context: this.createRouteContext(envelope, record.sourceNodeRid),
|
|
504
502
|
signal,
|
|
505
503
|
missingHandlerMessage: `No routed request handler is registered for '${this.routerChannelId}:${packetName}'.`,
|
|
506
|
-
writeReply:
|
|
504
|
+
writeReply: (reply) => {
|
|
507
505
|
requireMeshReplyAccepted(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, reply, codecs)));
|
|
508
506
|
},
|
|
509
|
-
writeError:
|
|
507
|
+
writeError: (error) => {
|
|
510
508
|
requireMeshReplyAccepted(record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error)));
|
|
511
509
|
}
|
|
512
510
|
});
|
|
@@ -558,7 +556,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
558
556
|
if (operation.submit() === false) {
|
|
559
557
|
throw new configuration_1.ZLinkConfigurationException('Route reply was not accepted by Core.');
|
|
560
558
|
}
|
|
561
|
-
return
|
|
559
|
+
return completedChannelReply;
|
|
562
560
|
}
|
|
563
561
|
createRouteContext(envelope, sourceRid) {
|
|
564
562
|
const sourceNodeRid = String(sourceRid ?? '');
|
|
@@ -573,3 +571,6 @@ class ZLinkRoutePacketDispatcher {
|
|
|
573
571
|
}
|
|
574
572
|
}
|
|
575
573
|
exports.ZLinkRoutePacketDispatcher = ZLinkRoutePacketDispatcher;
|
|
574
|
+
function isMeshRequest(record) {
|
|
575
|
+
return record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest || record.kind === service_runtime_contracts_1.ReceiveKind.ChannelRequest;
|
|
576
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
2
|
import type { ZLinkFlowOrigin } from '../../contracts';
|
|
3
|
-
import {
|
|
3
|
+
import { type ZLinkChannelEnvelopeHeader } from './channel-envelope';
|
|
4
4
|
export declare function tryDecodeChannelHeader(parts: readonly Message[], flowEnabled?: boolean): ZLinkChannelEnvelopeHeader | undefined;
|
|
5
5
|
/**
|
|
6
6
|
* Identifiers salvaged from a malformed channel envelope. Spec 27 §7: a
|
|
@@ -9,7 +9,6 @@ export declare function tryDecodeChannelHeader(parts: readonly Message[], flowEn
|
|
|
9
9
|
* present only when it is individually well-formed.
|
|
10
10
|
*/
|
|
11
11
|
export interface ZLinkMalformedChannelHeaderInfo {
|
|
12
|
-
readonly kind?: ZLinkChannelMessageKind;
|
|
13
12
|
readonly channelName?: string;
|
|
14
13
|
readonly messageName?: string;
|
|
15
14
|
readonly correlationId?: string;
|