@zlink-systems/framework 0.29.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/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/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +9 -4
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +3 -1
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +6 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +3 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +5 -0
- package/dist/runtime/application-jobs/contracts.d.ts +5 -1
- package/dist/runtime/backend/contracts/index.d.ts +10 -19
- package/dist/runtime/backend/mesh-completion-table.d.ts +6 -4
- package/dist/runtime/backend/mesh-completion-table.js +28 -18
- package/dist/runtime/backend/mesh-dispatch-pump.js +21 -25
- 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 +24 -29
- 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 +11 -6
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +10 -12
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +64 -98
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +10 -5
- package/dist/runtime/backend/raw-binding-port.d.ts +9 -2
- 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-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +15 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +193 -64
- 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-stateful-runtime.d.ts +7 -6
- package/dist/runtime/foundation/service-stateful-runtime.js +34 -23
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -2
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -3
- package/dist/runtime/foundation/service-topology-registry.js +9 -4
- package/dist/runtime/host/actor-packet-relay.js +7 -7
- package/dist/runtime/host/actor-runtime-options-factory.js +1 -1
- package/dist/runtime/host/application-job-queue.d.ts +11 -4
- package/dist/runtime/host/application-job-queue.js +66 -10
- package/dist/runtime/host/entry-actor-runtime.js +1 -1
- package/dist/runtime/host/index.js +15 -11
- 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/service-relocation-host-runtime.js +2 -2
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +25 -12
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -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/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/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/messaging/submission-result.d.ts +1 -1
- package/dist/runtime/messaging/submission-result.js +2 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +2 -0
- package/dist/runtime/spots/index.d.ts +4 -3
- package/dist/runtime/spots/index.js +14 -14
- package/dist/runtime/spots/spot-activation.d.ts +2 -1
- package/dist/runtime/spots/spot-activation.js +4 -4
- 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 +3 -1
- 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-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -1
- package/dist/runtime/streams/stream-session-runtime.js +1 -1
- package/package.json +3 -3
- 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/internal.ts +1 -0
- package/src/runtime/actors/actor-handoff.ts +13 -4
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +12 -2
- package/src/runtime/application-jobs/application-job-queue-scope.ts +6 -1
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +10 -18
- package/src/runtime/backend/mesh-completion-table.ts +36 -19
- package/src/runtime/backend/mesh-dispatch-pump.ts +19 -22
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +31 -29
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +19 -10
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +81 -111
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +12 -8
- package/src/runtime/backend/raw-binding-port.ts +12 -2
- 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-socket-registry.ts +84 -130
- package/src/runtime/diagnostics/message-flow.ts +1 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +268 -70
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +61 -35
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -79
- package/src/runtime/foundation/service-topology-registry.ts +13 -7
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-runtime-options-factory.ts +1 -0
- package/src/runtime/host/application-job-queue.ts +77 -10
- package/src/runtime/host/entry-actor-runtime.ts +1 -0
- package/src/runtime/host/index.ts +24 -5
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/service-relocation-host-runtime.ts +2 -0
- package/src/runtime/host/spot-address-transport.ts +45 -22
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- 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/location-store-repository.ts +220 -15
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/messaging/submission-result.ts +2 -2
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +2 -0
- package/src/runtime/spots/index.ts +16 -0
- package/src/runtime/spots/spot-activation.ts +5 -0
- 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 +3 -0
- package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +2 -0
- package/src/runtime/streams/stream-session-runtime.ts +1 -1
|
@@ -34,7 +34,12 @@ class ZLinkNodeChannelBackendAdapter {
|
|
|
34
34
|
return (0, node_socket_backend_adapter_1.wrapSocket)(node_backend_adapter_support_1.zlink.createDealerSocket(asNodeContext(context)), true);
|
|
35
35
|
}
|
|
36
36
|
createRouterSocket(context) {
|
|
37
|
-
|
|
37
|
+
const socket = node_backend_adapter_support_1.zlink.createRouterSocket(asNodeContext(context));
|
|
38
|
+
const adapter = (0, node_socket_backend_adapter_1.wrapSocket)(socket, true);
|
|
39
|
+
adapter.setReceiveFlowState = (state) => {
|
|
40
|
+
socket.setReceiveFlowState(state);
|
|
41
|
+
};
|
|
42
|
+
return adapter;
|
|
38
43
|
}
|
|
39
44
|
createPublisherSocket(context) {
|
|
40
45
|
return (0, node_socket_backend_adapter_1.wrapSocket)(node_backend_adapter_support_1.zlink.createPubSocket(asNodeContext(context)));
|
|
@@ -38,9 +38,10 @@ export declare function isRouteRecvRetryable(error: unknown): boolean;
|
|
|
38
38
|
export declare function submitBindingPublish(operation: ZLinkBindingPublishOperation, payload: unknown): void;
|
|
39
39
|
export declare function submitBindingReply(operation: ZLinkBindingReplyOperation, payload: unknown): void;
|
|
40
40
|
export declare function submitBindingAsyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): Promise<void>;
|
|
41
|
+
export declare function submitBindingSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): import('../raw-binding-port').ZLinkRawSendSubmission;
|
|
41
42
|
export declare function submitBindingSyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): void;
|
|
42
|
-
export declare function submitBindingRequest(operation: ZLinkBindingRequestOperation, payload: unknown, timeoutMs: number | undefined): Promise<readonly unknown[]>;
|
|
43
|
-
export declare function bindingRequestReply(submission: import('@zlink-systems/zlink').RequestSubmission, deadlineMs: number | undefined): Promise<import('@zlink-systems/zlink').Message[]>;
|
|
43
|
+
export declare function submitBindingRequest(operation: ZLinkBindingRequestOperation, payload: unknown, timeoutMs: number | undefined, recordReceived?: () => void): Promise<readonly unknown[]>;
|
|
44
|
+
export declare function bindingRequestReply(submission: import('@zlink-systems/zlink').RequestSubmission, deadlineMs: number | undefined, recordReceived?: () => void): Promise<import('@zlink-systems/zlink').Message[]>;
|
|
44
45
|
export declare function closeBindingReply(replies: readonly import('@zlink-systems/zlink').Message[]): void;
|
|
45
46
|
/**
|
|
46
47
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
@@ -50,7 +51,6 @@ export declare function closeBindingHandle(target: {
|
|
|
50
51
|
close(): void;
|
|
51
52
|
}): void;
|
|
52
53
|
export declare function isContextTerminatedError(error: unknown): boolean;
|
|
53
|
-
export declare function disableSocketLinger(target: unknown): void;
|
|
54
54
|
export declare function toNativeRoutingId(routingId: unknown): unknown;
|
|
55
55
|
export declare function translateBindingResultError(error: unknown, phase?: 'submit' | 'completion'): unknown;
|
|
56
56
|
export declare function toNativeActorRef(actor: unknown): unknown;
|
|
@@ -6,13 +6,13 @@ exports.isRouteRecvRetryable = isRouteRecvRetryable;
|
|
|
6
6
|
exports.submitBindingPublish = submitBindingPublish;
|
|
7
7
|
exports.submitBindingReply = submitBindingReply;
|
|
8
8
|
exports.submitBindingAsyncSend = submitBindingAsyncSend;
|
|
9
|
+
exports.submitBindingSend = submitBindingSend;
|
|
9
10
|
exports.submitBindingSyncSend = submitBindingSyncSend;
|
|
10
11
|
exports.submitBindingRequest = submitBindingRequest;
|
|
11
12
|
exports.bindingRequestReply = bindingRequestReply;
|
|
12
13
|
exports.closeBindingReply = closeBindingReply;
|
|
13
14
|
exports.closeBindingHandle = closeBindingHandle;
|
|
14
15
|
exports.isContextTerminatedError = isContextTerminatedError;
|
|
15
|
-
exports.disableSocketLinger = disableSocketLinger;
|
|
16
16
|
exports.toNativeRoutingId = toNativeRoutingId;
|
|
17
17
|
exports.translateBindingResultError = translateBindingResultError;
|
|
18
18
|
exports.toNativeActorRef = toNativeActorRef;
|
|
@@ -76,6 +76,11 @@ function submitBindingReply(operation, payload) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
async function submitBindingAsyncSend(operation, payload) {
|
|
79
|
+
const submission = submitBindingSend(operation, payload);
|
|
80
|
+
if (submission.result === runtime_values_1.SubmitResult.Backpressured)
|
|
81
|
+
await submission.admitted;
|
|
82
|
+
}
|
|
83
|
+
function submitBindingSend(operation, payload) {
|
|
79
84
|
let submission;
|
|
80
85
|
try {
|
|
81
86
|
let current;
|
|
@@ -91,13 +96,14 @@ async function submitBindingAsyncSend(operation, payload) {
|
|
|
91
96
|
throw translateBindingResultError(error, 'submit');
|
|
92
97
|
}
|
|
93
98
|
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
99
|
+
return {
|
|
100
|
+
result: submission.result,
|
|
101
|
+
admitted: submission.admitted.catch((error) => {
|
|
102
|
+
throw translateBindingResultError(error, 'completion');
|
|
103
|
+
})
|
|
104
|
+
};
|
|
100
105
|
}
|
|
106
|
+
return { result: runtime_values_1.SubmitResult.Ok, admitted: submission.admitted };
|
|
101
107
|
}
|
|
102
108
|
function submitBindingSyncSend(operation, payload) {
|
|
103
109
|
try {
|
|
@@ -114,7 +120,7 @@ function submitBindingSyncSend(operation, payload) {
|
|
|
114
120
|
throw translateBindingResultError(error);
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
|
-
async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
123
|
+
async function submitBindingRequest(operation, payload, timeoutMs, recordReceived) {
|
|
118
124
|
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
119
125
|
try {
|
|
120
126
|
let current;
|
|
@@ -132,25 +138,31 @@ async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
|
132
138
|
if (timeoutMs !== undefined) {
|
|
133
139
|
current = current.timeout(timeoutMs);
|
|
134
140
|
}
|
|
135
|
-
return await bindingRequestReply(current.submit(), deadlineMs);
|
|
141
|
+
return await bindingRequestReply(current.submit(), deadlineMs, recordReceived);
|
|
136
142
|
}
|
|
137
143
|
catch (error) {
|
|
138
144
|
throw translateBindingResultError(error);
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
|
-
async function bindingRequestReply(submission, deadlineMs) {
|
|
147
|
+
async function bindingRequestReply(submission, deadlineMs, recordReceived) {
|
|
142
148
|
const reply = submission.reply;
|
|
143
149
|
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
144
150
|
try {
|
|
145
151
|
const [, replies] = await (0, request_deadline_1.waitRequestReply)(Promise.all([submission.admitted, reply]), 'Request', deadlineMs);
|
|
152
|
+
recordReceived?.();
|
|
146
153
|
return replies;
|
|
147
154
|
}
|
|
148
155
|
catch (error) {
|
|
149
|
-
void reply.then(
|
|
156
|
+
void reply.then((parts) => {
|
|
157
|
+
recordReceived?.();
|
|
158
|
+
closeBindingReply(parts);
|
|
159
|
+
}, () => undefined);
|
|
150
160
|
throw error;
|
|
151
161
|
}
|
|
152
162
|
}
|
|
153
|
-
|
|
163
|
+
const replies = await reply;
|
|
164
|
+
recordReceived?.();
|
|
165
|
+
return replies;
|
|
154
166
|
}
|
|
155
167
|
function closeBindingReply(replies) {
|
|
156
168
|
for (const reply of replies)
|
|
@@ -182,23 +194,6 @@ function isSuccessfulOrAlreadyShutdownCloseError(error) {
|
|
|
182
194
|
function isContextTerminatedError(error) {
|
|
183
195
|
return error instanceof Error && /context was terminated/i.test(error.message);
|
|
184
196
|
}
|
|
185
|
-
function disableSocketLinger(target) {
|
|
186
|
-
if (target !== null &&
|
|
187
|
-
typeof target === 'object' &&
|
|
188
|
-
'options' in target &&
|
|
189
|
-
typeof target.options === 'object' &&
|
|
190
|
-
target.options !== null &&
|
|
191
|
-
'linger' in target.options) {
|
|
192
|
-
try {
|
|
193
|
-
target.options.linger = 0;
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
if (!isContextTerminatedError(error)) {
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
197
|
function toNativeRoutingId(routingId) {
|
|
203
198
|
if (typeof routingId === 'string')
|
|
204
199
|
return exports.zlink.RoutingId.from(routingId);
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import type { ZLinkBackendContext, ZLinkBackendMeshNode, ZLinkMeshBackendAdapter } from '../contracts';
|
|
2
2
|
export declare class ZLinkNodeMeshBackendAdapter implements ZLinkMeshBackendAdapter {
|
|
3
|
-
createMeshNode(context: ZLinkBackendContext, options:
|
|
4
|
-
readonly meshName: string;
|
|
5
|
-
readonly routingId?: string;
|
|
6
|
-
readonly receiveTimeoutMs?: number;
|
|
7
|
-
readonly trustProfile?: string;
|
|
8
|
-
readonly applicationJobQueue: import('../../application-jobs/contracts').ApplicationJobQueuePort;
|
|
9
|
-
readonly applicationJobReceiveFlowFailureSink?: (error: unknown) => void;
|
|
10
|
-
readonly peerAdmissionSealed?: () => boolean;
|
|
11
|
-
}): ZLinkBackendMeshNode;
|
|
3
|
+
createMeshNode(context: ZLinkBackendContext, options: Parameters<ZLinkMeshBackendAdapter['createMeshNode']>[1]): ZLinkBackendMeshNode;
|
|
12
4
|
}
|
|
@@ -12,7 +12,7 @@ class ZLinkNodeMeshBackendAdapter {
|
|
|
12
12
|
if (!isBindingContext(bindingContext)) {
|
|
13
13
|
throw new TypeError('Node MeshNode creation requires the Node binding Context owned by the host.');
|
|
14
14
|
}
|
|
15
|
-
return new node_raw_mesh_backend_1.ZLinkNodeRawMeshBackend(options.meshName, options.routingId, new node_raw_binding_port_1.ZLinkNodeRawBindingPort(bindingContext, options.receiveTimeoutMs), options.applicationJobQueue, options.applicationJobReceiveFlowFailureSink, options.peerAdmissionSealed);
|
|
15
|
+
return new node_raw_mesh_backend_1.ZLinkNodeRawMeshBackend(options.meshName, options.routingId, new node_raw_binding_port_1.ZLinkNodeRawBindingPort(bindingContext, options.receiveTimeoutMs), options.applicationJobQueue, options.applicationJobReceiveFlowFailureSink, options.peerAdmissionSealed, options.infrastructureTaskRunner);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.ZLinkNodeMeshBackendAdapter = ZLinkNodeMeshBackendAdapter;
|
|
@@ -114,10 +114,6 @@ class NodeRawSocketPort {
|
|
|
114
114
|
connectable(this.socket).disconnect(endpoint);
|
|
115
115
|
this.endpoints.delete(`connect\0${endpoint}`);
|
|
116
116
|
}
|
|
117
|
-
setReceiveFlowState(state) {
|
|
118
|
-
this.requireOpen();
|
|
119
|
-
this.socket.setReceiveFlowState(state === 'paused' ? zlink_1.ReceiveFlowState.PAUSED : zlink_1.ReceiveFlowState.RUNNING);
|
|
120
|
-
}
|
|
121
117
|
monitor() {
|
|
122
118
|
this.requireOpen();
|
|
123
119
|
const nativeMonitor = this.socket.monitorOpen();
|
|
@@ -178,6 +174,10 @@ class NodeRawSocketPort {
|
|
|
178
174
|
}
|
|
179
175
|
class NodeRawRouterPort extends NodeRawSocketPort {
|
|
180
176
|
nextIncomingRequestSequence = 1n;
|
|
177
|
+
setReceiveFlowState(state) {
|
|
178
|
+
this.requireOpen();
|
|
179
|
+
this.socket.setReceiveFlowState(state === 'paused' ? zlink_1.ReceiveFlowState.PAUSED : zlink_1.ReceiveFlowState.RUNNING);
|
|
180
|
+
}
|
|
181
181
|
disconnectRid(routingId) {
|
|
182
182
|
this.requireOpen();
|
|
183
183
|
this.socket.disconnectRid(bindingRoutingId(routingId));
|
|
@@ -209,7 +209,12 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
209
209
|
requireParts(parts);
|
|
210
210
|
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
submitSend(targetRid, parts) {
|
|
213
|
+
this.requireOpen();
|
|
214
|
+
requireParts(parts);
|
|
215
|
+
return (0, node_backend_adapter_support_1.submitBindingSend)(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
216
|
+
}
|
|
217
|
+
async request(targetRid, parts, timeoutMs, recordReceived) {
|
|
213
218
|
this.requireOpen();
|
|
214
219
|
const deadlineMs = performance.now() + timeoutMs;
|
|
215
220
|
let submission;
|
|
@@ -222,7 +227,7 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
222
227
|
throw (0, node_backend_adapter_support_1.translateBindingResultError)(error, 'submit');
|
|
223
228
|
}
|
|
224
229
|
try {
|
|
225
|
-
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs);
|
|
230
|
+
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs, recordReceived);
|
|
226
231
|
return copyAndClose(replies);
|
|
227
232
|
}
|
|
228
233
|
catch (error) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SubmitResult, type RequestResult as RequestResultValue, type SubmitResult as SubmitResultValue } from '@zlink-systems/zlink';
|
|
2
|
+
import type { ZLinkMeshCompletionHandler } from '../mesh-completion-table';
|
|
2
3
|
import { type RoutingId } from '../../../contracts';
|
|
3
4
|
import type { ApplicationJobQueuePort } from '../../application-jobs/contracts';
|
|
4
5
|
import type { ZLinkDispatchErrorReporter } from '../../channels/dispatch-error-reporter';
|
|
@@ -7,7 +8,7 @@ import type { ServiceInstanceActivationRecoveryEnvelope } from '../../foundation
|
|
|
7
8
|
import { type MeshOperationId, type MeshPeerEntry, type MeshPublisher, type ReadyBatch, type ReadyRecord, type ReceiveBatch, type ServiceSpot, type StreamSessionService, MeshNodeRuntimeState } from '../../foundation/service-runtime-contracts';
|
|
8
9
|
import type { ServiceActorRef, ServiceSpotState } from '../../foundation/service-stateful-registry';
|
|
9
10
|
import { type ServiceAsyncInstanceActivationAuthority, type ServiceInstanceApplicationLifecycle, type ServicePendingInstanceActivation, type ServiceSpotMessageFollowSeal, type ServiceUserSpotOperationHandler, type ServiceUserSpotOperationResult } from '../../foundation/service-stateful-runtime';
|
|
10
|
-
import type { ServiceActorCreateRecord, ServiceDirectSpotRouteFence, ServiceInstanceActivationTarget, ServiceInstanceRouteFence, ServiceSpotRouteFence, ServiceUserSpotCloseRecord, ServiceUserSpotCreateRecord } from '../../foundation/service-stateful-wire-codec';
|
|
11
|
+
import type { ServiceActorCreateRecord, ServiceDirectSpotRouteFence, ServiceInstanceActivationTarget, ServiceInstanceColdActivationTarget, ServiceInstanceRouteFence, ServiceSpotRouteFence, ServiceUserSpotCloseRecord, ServiceUserSpotCreateRecord } from '../../foundation/service-stateful-wire-codec';
|
|
11
12
|
import type { ServiceNodeDescriptor } from '../../foundation/service-topology-registry';
|
|
12
13
|
import { type ServiceApplicationPayload } from '../../foundation/service-wire-m6a-codec';
|
|
13
14
|
import type { ZLinkBackendActorRef, ZLinkBackendMeshNode, ZLinkBackendObjectPlacement } from '../contracts';
|
|
@@ -24,12 +25,11 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
24
25
|
private readonly applicationJobQueue?;
|
|
25
26
|
private readonly applicationJobReceiveFlowFailureSink?;
|
|
26
27
|
private readonly peerAdmissionSealed?;
|
|
28
|
+
private readonly infrastructureTaskRunner?;
|
|
27
29
|
readonly nativeInstance: this;
|
|
28
30
|
private readonly channels;
|
|
29
31
|
private readonly peerIntents;
|
|
30
|
-
private
|
|
31
|
-
private completionHead;
|
|
32
|
-
private completionCount;
|
|
32
|
+
private completionHandler?;
|
|
33
33
|
private readonly routingId;
|
|
34
34
|
private readonly lifecycleGeneration;
|
|
35
35
|
private bindEndpoint?;
|
|
@@ -56,7 +56,7 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
56
56
|
private messageFollowHandler?;
|
|
57
57
|
private dispatchErrors?;
|
|
58
58
|
private readonly peerDisconnectedHandlers;
|
|
59
|
-
constructor(meshName: string, routingId: string | undefined, bindingPort: ZLinkRawBindingPort, applicationJobQueue?: ApplicationJobQueuePort | undefined, applicationJobReceiveFlowFailureSink?: ((error: unknown) => void) | undefined, peerAdmissionSealed?: (() => boolean) | undefined);
|
|
59
|
+
constructor(meshName: string, routingId: string | undefined, bindingPort: ZLinkRawBindingPort, applicationJobQueue?: ApplicationJobQueuePort | undefined, applicationJobReceiveFlowFailureSink?: ((error: unknown) => void) | undefined, peerAdmissionSealed?: (() => boolean) | undefined, infrastructureTaskRunner?: import("../../spots/spot-actor-join-dispatch").ZLinkDetachedTaskRunner | undefined);
|
|
60
60
|
configureObjectPlacement(options: {
|
|
61
61
|
readonly role: ServiceNodeDescriptor['objectRole'];
|
|
62
62
|
readonly placementWeight: number;
|
|
@@ -79,8 +79,8 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
79
79
|
onPeerDisconnected(handler: (endpoint: string) => void): void;
|
|
80
80
|
selectObjectPlacement(stableType: string): ZLinkBackendObjectPlacement;
|
|
81
81
|
instanceSpotPlacementTypes(): readonly string[];
|
|
82
|
-
sendToMissingInstanceSpot(target:
|
|
83
|
-
requestToMissingInstanceSpot(target:
|
|
82
|
+
sendToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: MessageLike | readonly MessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): Promise<SubmitResult>;
|
|
83
|
+
requestToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: MessageLike | readonly MessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): MeshOperationId;
|
|
84
84
|
setRoutingId(routingId: unknown): void;
|
|
85
85
|
setBind(endpoint: string): void;
|
|
86
86
|
setAdvertiseHost(host: string): void;
|
|
@@ -151,6 +151,7 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
151
151
|
weights: number[];
|
|
152
152
|
};
|
|
153
153
|
createPublisher(): MeshPublisher;
|
|
154
|
+
setCompletionHandler(handler: ZLinkMeshCompletionHandler): void;
|
|
154
155
|
setReadyHandler(handler: (readyDomains: number) => number): void;
|
|
155
156
|
createReadyBatch(capacity: number): ReadyBatch;
|
|
156
157
|
createReceiveBatch(messageCapacity: number, partCapacity: number): ReceiveBatch;
|
|
@@ -249,11 +250,8 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
249
250
|
private notifyReady;
|
|
250
251
|
private observeCompletion;
|
|
251
252
|
private observeStateful;
|
|
252
|
-
private
|
|
253
|
-
private
|
|
254
|
-
private drainCompletions;
|
|
255
|
-
private takeCompletion;
|
|
256
|
-
private clearCompletions;
|
|
253
|
+
private observeImmediateFailure;
|
|
254
|
+
private deliverCompletion;
|
|
257
255
|
private drainMailbox;
|
|
258
256
|
private requireRuntime;
|
|
259
257
|
private requireApplicationJobQueue;
|
|
@@ -12,7 +12,6 @@ const EndpointNotation_1 = require("../../../contracts/Configuration/EndpointNot
|
|
|
12
12
|
const InternalDefaults_1 = require("../../../contracts/Configuration/InternalDefaults");
|
|
13
13
|
const Registration_1 = require("../../../contracts/Configuration/Registration");
|
|
14
14
|
const RegistrationBuilderPolicy_1 = require("../../../contracts/Configuration/RegistrationBuilderPolicy");
|
|
15
|
-
const admission_1 = require("../../admission");
|
|
16
15
|
const operation_identity_1 = require("../../foundation/operation-identity");
|
|
17
16
|
const operation_registry_1 = require("../../foundation/operation-registry");
|
|
18
17
|
const raw_service_mesh_runtime_1 = require("../../foundation/raw-service-mesh-runtime");
|
|
@@ -58,12 +57,11 @@ class ZLinkNodeRawMeshBackend {
|
|
|
58
57
|
applicationJobQueue;
|
|
59
58
|
applicationJobReceiveFlowFailureSink;
|
|
60
59
|
peerAdmissionSealed;
|
|
60
|
+
infrastructureTaskRunner;
|
|
61
61
|
nativeInstance = this;
|
|
62
62
|
channels = new Map();
|
|
63
63
|
peerIntents = new Map();
|
|
64
|
-
|
|
65
|
-
completionHead = 0;
|
|
66
|
-
completionCount = 0;
|
|
64
|
+
completionHandler;
|
|
67
65
|
routingId;
|
|
68
66
|
lifecycleGeneration;
|
|
69
67
|
bindEndpoint;
|
|
@@ -107,12 +105,13 @@ class ZLinkNodeRawMeshBackend {
|
|
|
107
105
|
messageFollowHandler;
|
|
108
106
|
dispatchErrors;
|
|
109
107
|
peerDisconnectedHandlers = new Set();
|
|
110
|
-
constructor(meshName, routingId, bindingPort, applicationJobQueue, applicationJobReceiveFlowFailureSink, peerAdmissionSealed) {
|
|
108
|
+
constructor(meshName, routingId, bindingPort, applicationJobQueue, applicationJobReceiveFlowFailureSink, peerAdmissionSealed, infrastructureTaskRunner) {
|
|
111
109
|
this.meshName = meshName;
|
|
112
110
|
this.bindingPort = bindingPort;
|
|
113
111
|
this.applicationJobQueue = applicationJobQueue;
|
|
114
112
|
this.applicationJobReceiveFlowFailureSink = applicationJobReceiveFlowFailureSink;
|
|
115
113
|
this.peerAdmissionSealed = peerAdmissionSealed;
|
|
114
|
+
this.infrastructureTaskRunner = infrastructureTaskRunner;
|
|
116
115
|
if (meshName.length === 0)
|
|
117
116
|
throw new TypeError('MeshName must be non-empty.');
|
|
118
117
|
if (routingId === undefined || routingId.length === 0) {
|
|
@@ -203,6 +202,8 @@ class ZLinkNodeRawMeshBackend {
|
|
|
203
202
|
resolveAdvertisedEndpoint: (boundEndpoint) => this.resolveAdvertisedEndpoint(boundEndpoint),
|
|
204
203
|
bindingPort: this.bindingPort,
|
|
205
204
|
applicationJobQueue: this.requireApplicationJobQueue(),
|
|
205
|
+
onReceiveReady: () => this.onReadable(true, false),
|
|
206
|
+
infrastructureTaskRunner: this.infrastructureTaskRunner,
|
|
206
207
|
peerAdmissionSealed: this.peerAdmissionSealed,
|
|
207
208
|
onReceiveFlowConfigFailure: this.applicationJobReceiveFlowFailureSink,
|
|
208
209
|
onMailboxReady: (domain) => this.readyHandler?.(domain === 'application' ? service_runtime_contracts_1.ReadyDomain.Application : service_runtime_contracts_1.ReadyDomain.Infrastructure),
|
|
@@ -275,7 +276,6 @@ class ZLinkNodeRawMeshBackend {
|
|
|
275
276
|
this.stateful = undefined;
|
|
276
277
|
this.runtime?.close();
|
|
277
278
|
this.runtime = undefined;
|
|
278
|
-
this.clearCompletions();
|
|
279
279
|
this.closed = true;
|
|
280
280
|
}
|
|
281
281
|
addChannelName(name) {
|
|
@@ -426,7 +426,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
426
426
|
admittedPeerCount: peers.length,
|
|
427
427
|
drainingPeerCount: peers.filter((peer) => peer.descriptor.state === 'draining').length,
|
|
428
428
|
pendingApplicationMessages: BigInt(this.runtime?.mailbox.pendingMessages('application') ?? 0),
|
|
429
|
-
pendingInfrastructureMessages: BigInt(
|
|
429
|
+
pendingInfrastructureMessages: BigInt(this.runtime?.mailbox.pendingMessages('infrastructure') ?? 0),
|
|
430
430
|
pendingBytes: BigInt((this.runtime?.mailbox.pendingBytes('application') ?? 0) +
|
|
431
431
|
(this.runtime?.mailbox.pendingBytes('infrastructure') ?? 0)),
|
|
432
432
|
lastError: 0,
|
|
@@ -519,6 +519,9 @@ class ZLinkNodeRawMeshBackend {
|
|
|
519
519
|
}
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
|
+
setCompletionHandler(handler) {
|
|
523
|
+
this.completionHandler = handler;
|
|
524
|
+
}
|
|
522
525
|
setReadyHandler(handler) {
|
|
523
526
|
this.readyHandler = handler;
|
|
524
527
|
this.notifyReady();
|
|
@@ -532,7 +535,6 @@ class ZLinkNodeRawMeshBackend {
|
|
|
532
535
|
drainReady(domains, batch) {
|
|
533
536
|
const target = requireRawReadyBatch(batch);
|
|
534
537
|
if ((domains & service_runtime_contracts_1.ReadyDomain.Infrastructure) !== 0) {
|
|
535
|
-
this.drainCompletions(target);
|
|
536
538
|
this.drainMailbox('infrastructure', target);
|
|
537
539
|
}
|
|
538
540
|
if ((domains & service_runtime_contracts_1.ReadyDomain.Application) !== 0) {
|
|
@@ -540,7 +542,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
540
542
|
}
|
|
541
543
|
const runtime = this.runtime;
|
|
542
544
|
const infrastructureResidue = (domains & service_runtime_contracts_1.ReadyDomain.Infrastructure) !== 0 &&
|
|
543
|
-
(
|
|
545
|
+
(runtime?.mailbox.pendingMessages('infrastructure') ?? 0) > 0;
|
|
544
546
|
const applicationResidue = (domains & service_runtime_contracts_1.ReadyDomain.Application) !== 0 &&
|
|
545
547
|
(runtime?.mailbox.pendingMessages('application') ?? 0) > 0;
|
|
546
548
|
return {
|
|
@@ -719,7 +721,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
719
721
|
closeActorBoundSession(actor, expectedBindingGeneration, timeoutMs = Registration_1.DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
720
722
|
const binding = this.requireStateful().registry.binding(actor);
|
|
721
723
|
if (binding === undefined) {
|
|
722
|
-
return this.
|
|
724
|
+
return this.observeImmediateFailure(service_runtime_contracts_1.OperationKind.StreamUnbind, zlink_1.RequestResult.NotFound);
|
|
723
725
|
}
|
|
724
726
|
return this.observeStateful(service_runtime_contracts_1.OperationKind.StreamUnbind, this.requireStateful().unbindSession(binding.sessionRid, actor, expectedBindingGeneration, timeoutMs));
|
|
725
727
|
}
|
|
@@ -824,7 +826,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
824
826
|
notifyReady() {
|
|
825
827
|
const runtime = this.runtime;
|
|
826
828
|
let domains = service_runtime_contracts_1.ReadyDomain.None;
|
|
827
|
-
if (
|
|
829
|
+
if ((runtime?.mailbox.pendingMessages('infrastructure') ?? 0) > 0) {
|
|
828
830
|
domains |= service_runtime_contracts_1.ReadyDomain.Infrastructure;
|
|
829
831
|
}
|
|
830
832
|
if ((runtime?.mailbox.pendingMessages('application') ?? 0) > 0) {
|
|
@@ -835,61 +837,31 @@ class ZLinkNodeRawMeshBackend {
|
|
|
835
837
|
}
|
|
836
838
|
observeCompletion(low, operationKind, promise) {
|
|
837
839
|
const id = { high: 1n, low };
|
|
838
|
-
void promise.then((result) => this.
|
|
840
|
+
void promise.then((result) => this.deliverCompletion(id, operationKind, result), (error) => this.deliverCompletion(id, operationKind, requestFailureResult(error)));
|
|
839
841
|
return id;
|
|
840
842
|
}
|
|
841
843
|
observeStateful(operationKind, pending) {
|
|
842
844
|
const id = { high: operation_identity_1.ZLINK_NATIVE_CORRELATION_OPERATION_NAMESPACE, low: pending.id };
|
|
843
|
-
void pending.promise.then((result) => this.
|
|
845
|
+
void pending.promise.then((result) => this.deliverCompletion(id, operationKind, result), (error) => this.deliverCompletion(id, operationKind, requestFailureResult(error)));
|
|
844
846
|
return id;
|
|
845
847
|
}
|
|
846
|
-
|
|
848
|
+
observeImmediateFailure(operationKind, terminalResult) {
|
|
847
849
|
const low = this.nextPeerIntent++;
|
|
848
|
-
|
|
849
|
-
this.enqueueCompletion(id, operationKind, { terminalResult, failureCode: 0 });
|
|
850
|
-
return id;
|
|
850
|
+
return this.observeCompletion(low, operationKind, Promise.resolve({ terminalResult, failureCode: 0 }));
|
|
851
851
|
}
|
|
852
|
-
|
|
853
|
-
if (this.
|
|
852
|
+
deliverCompletion(operationId, operationKind, result) {
|
|
853
|
+
if (this.completionHandler !== undefined) {
|
|
854
|
+
this.completionHandler({ operationId, terminalResult: result.terminalResult }, () => completionRecord(operationId, operationKind, result));
|
|
854
855
|
return;
|
|
855
|
-
this.completions.push({ operationId, operationKind, result });
|
|
856
|
-
this.completionCount += 1;
|
|
857
|
-
this.readyHandler?.(service_runtime_contracts_1.ReadyDomain.Infrastructure);
|
|
858
|
-
}
|
|
859
|
-
drainCompletions(batch) {
|
|
860
|
-
while (!batch.full && this.completionCount > 0) {
|
|
861
|
-
const completion = this.takeCompletion();
|
|
862
|
-
if (completion === undefined)
|
|
863
|
-
continue;
|
|
864
|
-
batch.push({
|
|
865
|
-
ownerKind: service_runtime_contracts_1.ReadyOwnerKind.Node,
|
|
866
|
-
domain: service_runtime_contracts_1.ReadyDomain.Infrastructure,
|
|
867
|
-
spotId: null,
|
|
868
|
-
actor: null,
|
|
869
|
-
terminalCompletion: true
|
|
870
|
-
}, new CompletionClaim(completion));
|
|
871
856
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
if (this.completionCount === 0) {
|
|
881
|
-
this.clearCompletions();
|
|
882
|
-
}
|
|
883
|
-
else if ((0, admission_1.shouldCompactBackingArray)(this.completionHead, this.completions.length)) {
|
|
884
|
-
this.completions.splice(0, this.completionHead);
|
|
885
|
-
this.completionHead = 0;
|
|
886
|
-
}
|
|
887
|
-
return completion;
|
|
888
|
-
}
|
|
889
|
-
clearCompletions() {
|
|
890
|
-
this.completions.length = 0;
|
|
891
|
-
this.completionHead = 0;
|
|
892
|
-
this.completionCount = 0;
|
|
857
|
+
// The raw pull contract uses the existing infrastructure mailbox. A
|
|
858
|
+
// registered Framework owner receives the terminal directly above.
|
|
859
|
+
this.runtime?.mailbox.tryEnqueue({
|
|
860
|
+
owner: this.routingId,
|
|
861
|
+
domain: 'infrastructure',
|
|
862
|
+
parts: [],
|
|
863
|
+
completion: completionRecord(operationId, operationKind, result)
|
|
864
|
+
});
|
|
893
865
|
}
|
|
894
866
|
drainMailbox(domain, batch) {
|
|
895
867
|
const runtime = this.runtime;
|
|
@@ -899,7 +871,15 @@ class ZLinkNodeRawMeshBackend {
|
|
|
899
871
|
const claim = runtime.mailbox.tryClaim(domain, MAX_DRAIN_RECORDS, Number.MAX_SAFE_INTEGER);
|
|
900
872
|
if (claim === undefined)
|
|
901
873
|
break;
|
|
902
|
-
const owner =
|
|
874
|
+
const owner = claim.records[0]?.completion === undefined
|
|
875
|
+
? readyOwner(claim.owner, this.routingId, this.stateful, domain)
|
|
876
|
+
: {
|
|
877
|
+
ownerKind: service_runtime_contracts_1.ReadyOwnerKind.Node,
|
|
878
|
+
domain: service_runtime_contracts_1.ReadyDomain.Infrastructure,
|
|
879
|
+
spotId: null,
|
|
880
|
+
actor: null,
|
|
881
|
+
terminalCompletion: true
|
|
882
|
+
};
|
|
903
883
|
batch.push(owner, new MailboxClaim(runtime, claim));
|
|
904
884
|
}
|
|
905
885
|
}
|
|
@@ -1259,49 +1239,35 @@ class MailboxClaim {
|
|
|
1259
1239
|
this.runtime.mailbox.release(this.claim, this.remaining);
|
|
1260
1240
|
}
|
|
1261
1241
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
applicationMetadata: null,
|
|
1288
|
-
kindData: 'kindData' in this.completion.result ? (this.completion.result.kindData ?? null) : null,
|
|
1289
|
-
terminalResult: this.completion.result.terminalResult,
|
|
1290
|
-
failureErrno: this.completion.result.failureCode,
|
|
1291
|
-
parts: payload === undefined
|
|
1292
|
-
? []
|
|
1293
|
-
: payload.contentType === MULTIPART_CONTENT_TYPE
|
|
1294
|
-
? decodeMultipart(payload.payload)
|
|
1295
|
-
: [zlink_1.Message.from(payload.payload)],
|
|
1296
|
-
reply: () => zlink_1.SubmitResult.InvalidState,
|
|
1297
|
-
replyActorJoin: () => zlink_1.SubmitResult.NotSupported
|
|
1298
|
-
}
|
|
1299
|
-
]
|
|
1300
|
-
};
|
|
1301
|
-
}
|
|
1302
|
-
release() { }
|
|
1242
|
+
function completionRecord(operationId, operationKind, result) {
|
|
1243
|
+
const payload = result.payload;
|
|
1244
|
+
return {
|
|
1245
|
+
kind: service_runtime_contracts_1.ReceiveKind.Completion,
|
|
1246
|
+
domain: service_runtime_contracts_1.ReadyDomain.Infrastructure,
|
|
1247
|
+
sourceNodeRid: null,
|
|
1248
|
+
sourceSpotId: null,
|
|
1249
|
+
sourceBindingGeneration: 0n,
|
|
1250
|
+
sourceActor: null,
|
|
1251
|
+
operationId,
|
|
1252
|
+
operationKind,
|
|
1253
|
+
channelName: null,
|
|
1254
|
+
topic: null,
|
|
1255
|
+
applicationMetadata: null,
|
|
1256
|
+
kindData: 'kindData' in result ? (result.kindData ?? null) : null,
|
|
1257
|
+
terminalResult: result.terminalResult,
|
|
1258
|
+
failureErrno: result.failureCode,
|
|
1259
|
+
parts: payload === undefined
|
|
1260
|
+
? []
|
|
1261
|
+
: payload.contentType === MULTIPART_CONTENT_TYPE
|
|
1262
|
+
? decodeMultipart(payload.payload)
|
|
1263
|
+
: [runtime_message_1.ZLinkBufferMessage.from(payload.payload)],
|
|
1264
|
+
reply: () => zlink_1.SubmitResult.InvalidState,
|
|
1265
|
+
replyActorJoin: () => zlink_1.SubmitResult.NotSupported
|
|
1266
|
+
};
|
|
1303
1267
|
}
|
|
1304
1268
|
function decodeMultipartRecord(runtime, record) {
|
|
1269
|
+
if (record.completion !== undefined)
|
|
1270
|
+
return record.completion;
|
|
1305
1271
|
const stateful = (0, service_stateful_runtime_1.statefulMailboxData)(record);
|
|
1306
1272
|
if (stateful !== undefined) {
|
|
1307
1273
|
return decodeStatefulRecord(record, stateful);
|
|
@@ -10,6 +10,8 @@ const node_event_loop_poller_1 = require("./node-event-loop-poller");
|
|
|
10
10
|
const eventLoopPollers = new WeakMap();
|
|
11
11
|
function wrapSocket(nativeInstance, pollCompletion) {
|
|
12
12
|
const socket = nativeInstance;
|
|
13
|
+
if (socket.options !== undefined)
|
|
14
|
+
socket.options.linger = 0;
|
|
13
15
|
const hasRequest = typeof nativeInstance.request === 'function';
|
|
14
16
|
const hasRoutedPeer = hasRequest && typeof nativeInstance.reply === 'function';
|
|
15
17
|
const hasStream = typeof nativeInstance.recvPacket === 'function';
|
|
@@ -18,9 +20,9 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
18
20
|
: new node_event_loop_poller_1.ZLinkNodeEventLoopPoller(nativeInstance, pollCompletion, () => { });
|
|
19
21
|
const adapter = {
|
|
20
22
|
nativeInstance,
|
|
23
|
+
receiveAdmission: undefined,
|
|
21
24
|
async dispose() {
|
|
22
25
|
eventLoopPoller?.dispose();
|
|
23
|
-
(0, node_backend_adapter_support_1.disableSocketLinger)(nativeInstance);
|
|
24
26
|
(0, node_backend_adapter_support_1.closeBindingHandle)(nativeInstance);
|
|
25
27
|
},
|
|
26
28
|
close() {
|
|
@@ -44,9 +46,6 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
44
46
|
.setChannelName;
|
|
45
47
|
setChannelName?.call(nativeInstance, channelName);
|
|
46
48
|
},
|
|
47
|
-
setReceiveFlowState(state) {
|
|
48
|
-
nativeInstance.setReceiveFlowState(state);
|
|
49
|
-
},
|
|
50
49
|
setProbe(enabled) {
|
|
51
50
|
requireSocketOptions(socket).probe = enabled;
|
|
52
51
|
},
|
|
@@ -68,6 +67,12 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
68
67
|
setRoutingId(routingId) {
|
|
69
68
|
nativeInstance.setRoutingId((0, node_backend_adapter_support_1.toNativeRoutingId)(routingId));
|
|
70
69
|
},
|
|
70
|
+
get lingerMs() {
|
|
71
|
+
return requireSocketOptions(socket).linger;
|
|
72
|
+
},
|
|
73
|
+
set lingerMs(value) {
|
|
74
|
+
requireSocketOptions(socket).linger = value;
|
|
75
|
+
},
|
|
71
76
|
get peerWeight() {
|
|
72
77
|
return socket.options?.peerWeight ?? RegistrationBuilderPolicy_1.ZLINK_DEFAULT_PUBLIC_WEIGHT;
|
|
73
78
|
},
|
|
@@ -144,7 +149,7 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
144
149
|
}
|
|
145
150
|
if (hasRequest) {
|
|
146
151
|
const [payload, timeoutMs] = args;
|
|
147
|
-
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.request(), payload, timeoutMs);
|
|
152
|
+
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.request(), payload, timeoutMs, adapter.receiveAdmission?.recordReceived);
|
|
148
153
|
}
|
|
149
154
|
throw new TypeError('Backend request requires a DEALER or ROUTER socket.');
|
|
150
155
|
},
|