@zlink-systems/zlink 0.17.3
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 +373 -0
- package/README.md +198 -0
- package/README.typedoc.md +56 -0
- package/THIRD_PARTY_NOTICES.md +84 -0
- package/binding.gyp +27 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +117 -0
- package/dist/index.mjs +4 -0
- package/dist/zlink/contracts/core/buffer_like.d.ts +2 -0
- package/dist/zlink/contracts/core/buffer_like.js +3 -0
- package/dist/zlink/contracts/core/context.d.ts +103 -0
- package/dist/zlink/contracts/core/context.js +11 -0
- package/dist/zlink/contracts/core/index.d.ts +3 -0
- package/dist/zlink/contracts/core/index.js +20 -0
- package/dist/zlink/contracts/core/routing_id.d.ts +28 -0
- package/dist/zlink/contracts/core/routing_id.js +120 -0
- package/dist/zlink/contracts/errors/errors.d.ts +44 -0
- package/dist/zlink/contracts/errors/errors.js +89 -0
- package/dist/zlink/contracts/errors/index.d.ts +2 -0
- package/dist/zlink/contracts/errors/index.js +29 -0
- package/dist/zlink/contracts/errors/results.d.ts +106 -0
- package/dist/zlink/contracts/errors/results.js +102 -0
- package/dist/zlink/contracts/eventing/index.d.ts +3 -0
- package/dist/zlink/contracts/eventing/index.js +20 -0
- package/dist/zlink/contracts/eventing/monitor.d.ts +157 -0
- package/dist/zlink/contracts/eventing/monitor.js +82 -0
- package/dist/zlink/contracts/eventing/poller.d.ts +76 -0
- package/dist/zlink/contracts/eventing/poller.js +3 -0
- package/dist/zlink/contracts/eventing/timer.d.ts +38 -0
- package/dist/zlink/contracts/eventing/timer.js +3 -0
- package/dist/zlink/contracts/index.d.ts +5 -0
- package/dist/zlink/contracts/index.js +22 -0
- package/dist/zlink/contracts/messaging/handlers.d.ts +5 -0
- package/dist/zlink/contracts/messaging/handlers.js +3 -0
- package/dist/zlink/contracts/messaging/index.d.ts +8 -0
- package/dist/zlink/contracts/messaging/index.js +15 -0
- package/dist/zlink/contracts/messaging/message.d.ts +68 -0
- package/dist/zlink/contracts/messaging/message.js +280 -0
- package/dist/zlink/contracts/messaging/message_parts_envelope.d.ts +14 -0
- package/dist/zlink/contracts/messaging/message_parts_envelope.js +56 -0
- package/dist/zlink/contracts/messaging/operations.d.ts +54 -0
- package/dist/zlink/contracts/messaging/operations.js +3 -0
- package/dist/zlink/contracts/messaging/received.d.ts +41 -0
- package/dist/zlink/contracts/messaging/received.js +130 -0
- package/dist/zlink/contracts/messaging/stream_packet.d.ts +14 -0
- package/dist/zlink/contracts/messaging/stream_packet.js +33 -0
- package/dist/zlink/contracts/messaging/subscription_event.d.ts +12 -0
- package/dist/zlink/contracts/messaging/subscription_event.js +20 -0
- package/dist/zlink/contracts/messaging/topic_message.d.ts +14 -0
- package/dist/zlink/contracts/messaging/topic_message.js +36 -0
- package/dist/zlink/contracts/sockets/dealer_socket.d.ts +29 -0
- package/dist/zlink/contracts/sockets/dealer_socket.js +3 -0
- package/dist/zlink/contracts/sockets/index.d.ts +10 -0
- package/dist/zlink/contracts/sockets/index.js +15 -0
- package/dist/zlink/contracts/sockets/pair_socket.d.ts +20 -0
- package/dist/zlink/contracts/sockets/pair_socket.js +3 -0
- package/dist/zlink/contracts/sockets/pubsub_sockets.d.ts +40 -0
- package/dist/zlink/contracts/sockets/pubsub_sockets.js +3 -0
- package/dist/zlink/contracts/sockets/router_socket.d.ts +32 -0
- package/dist/zlink/contracts/sockets/router_socket.js +3 -0
- package/dist/zlink/contracts/sockets/socket.d.ts +58 -0
- package/dist/zlink/contracts/sockets/socket.js +3 -0
- package/dist/zlink/contracts/sockets/socket_constants.d.ts +88 -0
- package/dist/zlink/contracts/sockets/socket_constants.js +67 -0
- package/dist/zlink/contracts/sockets/socket_options.d.ts +105 -0
- package/dist/zlink/contracts/sockets/socket_options.js +3 -0
- package/dist/zlink/contracts/sockets/stream_socket.d.ts +31 -0
- package/dist/zlink/contracts/sockets/stream_socket.js +3 -0
- package/dist/zlink/runtime/buffers/message_conversion.d.ts +6 -0
- package/dist/zlink/runtime/buffers/message_conversion.js +49 -0
- package/dist/zlink/runtime/core/context.d.ts +43 -0
- package/dist/zlink/runtime/core/context.js +150 -0
- package/dist/zlink/runtime/core/context_options.d.ts +19 -0
- package/dist/zlink/runtime/core/context_options.js +23 -0
- package/dist/zlink/runtime/core/routing_id.d.ts +3 -0
- package/dist/zlink/runtime/core/routing_id.js +30 -0
- package/dist/zlink/runtime/core/routing_id_conversion.d.ts +2 -0
- package/dist/zlink/runtime/core/routing_id_conversion.js +11 -0
- package/dist/zlink/runtime/core/runtime_info.d.ts +8 -0
- package/dist/zlink/runtime/core/runtime_info.js +39 -0
- package/dist/zlink/runtime/errors/error_mapping.d.ts +4 -0
- package/dist/zlink/runtime/errors/error_mapping.js +132 -0
- package/dist/zlink/runtime/errors/error_state.d.ts +1 -0
- package/dist/zlink/runtime/errors/error_state.js +15 -0
- package/dist/zlink/runtime/errors/native_errors.d.ts +16 -0
- package/dist/zlink/runtime/errors/native_errors.js +86 -0
- package/dist/zlink/runtime/eventing/counters.d.ts +16 -0
- package/dist/zlink/runtime/eventing/counters.js +33 -0
- package/dist/zlink/runtime/eventing/index.d.ts +6 -0
- package/dist/zlink/runtime/eventing/index.js +22 -0
- package/dist/zlink/runtime/eventing/monitor_event_state.d.ts +3 -0
- package/dist/zlink/runtime/eventing/monitor_event_state.js +19 -0
- package/dist/zlink/runtime/eventing/monitor_raw.d.ts +50 -0
- package/dist/zlink/runtime/eventing/monitor_raw.js +3 -0
- package/dist/zlink/runtime/eventing/monitor_socket.d.ts +9 -0
- package/dist/zlink/runtime/eventing/monitor_socket.js +39 -0
- package/dist/zlink/runtime/eventing/monitor_status.d.ts +3 -0
- package/dist/zlink/runtime/eventing/monitor_status.js +52 -0
- package/dist/zlink/runtime/eventing/poll_events.d.ts +20 -0
- package/dist/zlink/runtime/eventing/poll_events.js +92 -0
- package/dist/zlink/runtime/eventing/poller.d.ts +34 -0
- package/dist/zlink/runtime/eventing/poller.js +275 -0
- package/dist/zlink/runtime/eventing/thread.d.ts +6 -0
- package/dist/zlink/runtime/eventing/thread.js +52 -0
- package/dist/zlink/runtime/eventing/timer.d.ts +8 -0
- package/dist/zlink/runtime/eventing/timer.js +45 -0
- package/dist/zlink/runtime/handles/native_handle.d.ts +7 -0
- package/dist/zlink/runtime/handles/native_handle.js +24 -0
- package/dist/zlink/runtime/messaging/completion_owner.d.ts +86 -0
- package/dist/zlink/runtime/messaging/completion_owner.js +570 -0
- package/dist/zlink/runtime/messaging/message_materializer.d.ts +36 -0
- package/dist/zlink/runtime/messaging/message_materializer.js +199 -0
- package/dist/zlink/runtime/messaging/message_parts_state.d.ts +4 -0
- package/dist/zlink/runtime/messaging/message_parts_state.js +20 -0
- package/dist/zlink/runtime/messaging/message_snapshot.d.ts +13 -0
- package/dist/zlink/runtime/messaging/message_snapshot.js +42 -0
- package/dist/zlink/runtime/messaging/received_operations.d.ts +5 -0
- package/dist/zlink/runtime/messaging/received_operations.js +46 -0
- package/dist/zlink/runtime/messaging/received_state.d.ts +13 -0
- package/dist/zlink/runtime/messaging/received_state.js +29 -0
- package/dist/zlink/runtime/messaging/request_executor.d.ts +2 -0
- package/dist/zlink/runtime/messaging/request_executor.js +8 -0
- package/dist/zlink/runtime/messaging/send_operation_base.d.ts +13 -0
- package/dist/zlink/runtime/messaging/send_operation_base.js +52 -0
- package/dist/zlink/runtime/messaging/subscription_event_state.d.ts +4 -0
- package/dist/zlink/runtime/messaging/subscription_event_state.js +17 -0
- package/dist/zlink/runtime/messaging/topic_message_state.d.ts +11 -0
- package/dist/zlink/runtime/messaging/topic_message_state.js +75 -0
- package/dist/zlink/runtime/native/binding.d.ts +6 -0
- package/dist/zlink/runtime/native/binding.js +3 -0
- package/dist/zlink/runtime/native/binding_context.d.ts +14 -0
- package/dist/zlink/runtime/native/binding_context.js +3 -0
- package/dist/zlink/runtime/native/binding_core.d.ts +21 -0
- package/dist/zlink/runtime/native/binding_core.js +3 -0
- package/dist/zlink/runtime/native/binding_eventing.d.ts +40 -0
- package/dist/zlink/runtime/native/binding_eventing.js +3 -0
- package/dist/zlink/runtime/native/binding_socket.d.ts +52 -0
- package/dist/zlink/runtime/native/binding_socket.js +3 -0
- package/dist/zlink/runtime/native/binding_types.d.ts +8 -0
- package/dist/zlink/runtime/native/binding_types.js +3 -0
- package/dist/zlink/runtime/native/native.d.ts +2 -0
- package/dist/zlink/runtime/native/native.js +40 -0
- package/dist/zlink/runtime/native/native_load_paths.d.ts +16 -0
- package/dist/zlink/runtime/native/native_load_paths.js +165 -0
- package/dist/zlink/runtime/options/byte_values.d.ts +3 -0
- package/dist/zlink/runtime/options/byte_values.js +27 -0
- package/dist/zlink/runtime/options/option_mapping.d.ts +72 -0
- package/dist/zlink/runtime/options/option_mapping.js +41 -0
- package/dist/zlink/runtime/options/validation.d.ts +1 -0
- package/dist/zlink/runtime/options/validation.js +17 -0
- package/dist/zlink/runtime/public_bridge.d.ts +6 -0
- package/dist/zlink/runtime/public_bridge.js +23 -0
- package/dist/zlink/runtime/sockets/dealer_socket.d.ts +16 -0
- package/dist/zlink/runtime/sockets/dealer_socket.js +56 -0
- package/dist/zlink/runtime/sockets/index.d.ts +19 -0
- package/dist/zlink/runtime/sockets/index.js +27 -0
- package/dist/zlink/runtime/sockets/pair_socket.d.ts +7 -0
- package/dist/zlink/runtime/sockets/pair_socket.js +12 -0
- package/dist/zlink/runtime/sockets/pub_socket.d.ts +7 -0
- package/dist/zlink/runtime/sockets/pub_socket.js +12 -0
- package/dist/zlink/runtime/sockets/router_socket.d.ts +19 -0
- package/dist/zlink/runtime/sockets/router_socket.js +70 -0
- package/dist/zlink/runtime/sockets/socket_base.d.ts +21 -0
- package/dist/zlink/runtime/sockets/socket_base.js +102 -0
- package/dist/zlink/runtime/sockets/socket_operation_builders.d.ts +38 -0
- package/dist/zlink/runtime/sockets/socket_operation_builders.js +93 -0
- package/dist/zlink/runtime/sockets/socket_operations.d.ts +40 -0
- package/dist/zlink/runtime/sockets/socket_operations.js +177 -0
- package/dist/zlink/runtime/sockets/socket_options.d.ts +104 -0
- package/dist/zlink/runtime/sockets/socket_options.js +259 -0
- package/dist/zlink/runtime/sockets/socket_submit_errors.d.ts +3 -0
- package/dist/zlink/runtime/sockets/socket_submit_errors.js +13 -0
- package/dist/zlink/runtime/sockets/stream_socket.d.ts +15 -0
- package/dist/zlink/runtime/sockets/stream_socket.js +93 -0
- package/dist/zlink/runtime/sockets/sub_socket.d.ts +7 -0
- package/dist/zlink/runtime/sockets/sub_socket.js +12 -0
- package/dist/zlink/runtime/sockets/xpub_socket.d.ts +10 -0
- package/dist/zlink/runtime/sockets/xpub_socket.js +39 -0
- package/dist/zlink/runtime/sockets/xsub_socket.d.ts +7 -0
- package/dist/zlink/runtime/sockets/xsub_socket.js +12 -0
- package/native/src/addon.cc +11 -0
- package/native/src/addon_common_api.h +57 -0
- package/native/src/addon_core.cc +3974 -0
- package/native/src/addon_core_api.h +110 -0
- package/native/src/addon_core_options.cc +119 -0
- package/native/src/addon_core_options.h +9 -0
- package/native/src/addon_exports.cc +151 -0
- package/native/src/addon_exports.h +7 -0
- package/native/src/addon_message_parts.h +67 -0
- package/native/src/addon_message_values.h +345 -0
- package/native/src/addon_monitor_status_values.h +71 -0
- package/native/src/addon_submit_results.h +30 -0
- package/package.json +74 -0
- package/prebuilds/linux-x64/libzlink.so.0.17.3 +0 -0
- package/prebuilds/linux-x64/zlink.node +0 -0
- package/provenance/core-package-provenance.json +73 -0
- package/scripts/install.js +37 -0
- package/scripts/resolve_core.js +86 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Received = exports.ReplyToken = void 0;
|
|
5
|
+
exports.createReplyToken = createReplyToken;
|
|
6
|
+
exports.replyTokenOwnerMatches = replyTokenOwnerMatches;
|
|
7
|
+
exports.replyTokenNativeValue = replyTokenNativeValue;
|
|
8
|
+
const errors_1 = require("../errors/errors");
|
|
9
|
+
const message_parts_envelope_1 = require("./message_parts_envelope");
|
|
10
|
+
const replyTokenOwnerIds = new WeakMap();
|
|
11
|
+
let nextReplyTokenOwnerId = 1;
|
|
12
|
+
let makeReplyToken;
|
|
13
|
+
let tokenOwnerMatches;
|
|
14
|
+
let tokenNativeValue;
|
|
15
|
+
/** Opaque capability required to reply to one ROUTER request. */
|
|
16
|
+
class ReplyToken {
|
|
17
|
+
#owner;
|
|
18
|
+
#value;
|
|
19
|
+
constructor(secret, owner, value) {
|
|
20
|
+
if (secret !== replyTokenSecret || value === 0n) {
|
|
21
|
+
throw new TypeError('ReplyToken values are created by ROUTER request receive');
|
|
22
|
+
}
|
|
23
|
+
this.#owner = owner;
|
|
24
|
+
this.#value = value;
|
|
25
|
+
Object.freeze(this);
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
makeReplyToken = (owner, value) => new ReplyToken(replyTokenSecret, owner, value);
|
|
29
|
+
// Keep the capability in its private fields only. Package-private
|
|
30
|
+
// readers use the same brand check instead of duplicating every token
|
|
31
|
+
// in a WeakMap with a second owner/value record.
|
|
32
|
+
tokenOwnerMatches = (token, owner) => typeof token === 'object' && token !== null
|
|
33
|
+
&& #owner in token && token.#owner === owner;
|
|
34
|
+
tokenNativeValue = (token) => {
|
|
35
|
+
if (typeof token !== 'object' || token === null || !(#value in token)) {
|
|
36
|
+
throw new TypeError('invalid ReplyToken');
|
|
37
|
+
}
|
|
38
|
+
return token.#value;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
equals(other) {
|
|
42
|
+
return other instanceof ReplyToken
|
|
43
|
+
&& this.#owner === other.#owner
|
|
44
|
+
&& this.#value === other.#value;
|
|
45
|
+
}
|
|
46
|
+
hashCode() {
|
|
47
|
+
let ownerId = replyTokenOwnerIds.get(this.#owner);
|
|
48
|
+
if (ownerId === undefined) {
|
|
49
|
+
ownerId = nextReplyTokenOwnerId++;
|
|
50
|
+
replyTokenOwnerIds.set(this.#owner, ownerId);
|
|
51
|
+
}
|
|
52
|
+
const valueHash = Number((this.#value ^ (this.#value >> 32n)) & 0xffffffffn);
|
|
53
|
+
return (Math.imul(ownerId, 0x9e3779b1) ^ valueHash) | 0;
|
|
54
|
+
}
|
|
55
|
+
toString() { return 'ReplyToken'; }
|
|
56
|
+
}
|
|
57
|
+
exports.ReplyToken = ReplyToken;
|
|
58
|
+
const replyTokenSecret = Symbol('ReplyToken');
|
|
59
|
+
/** @internal Package-private receive factory; not exported from the package root. */
|
|
60
|
+
function createReplyToken(owner, value) {
|
|
61
|
+
return makeReplyToken(owner, value);
|
|
62
|
+
}
|
|
63
|
+
/** @internal */
|
|
64
|
+
function replyTokenOwnerMatches(token, owner) {
|
|
65
|
+
return tokenOwnerMatches(token, owner);
|
|
66
|
+
}
|
|
67
|
+
/** @internal */
|
|
68
|
+
function replyTokenNativeValue(token) {
|
|
69
|
+
return tokenNativeValue(token);
|
|
70
|
+
}
|
|
71
|
+
function invalidReplyContextError() {
|
|
72
|
+
const error = new errors_1.SubmitError(errors_1.SubmitResult.InvalidState, 0);
|
|
73
|
+
error.message = 'reply is only valid for request-reply receive contexts';
|
|
74
|
+
return error;
|
|
75
|
+
}
|
|
76
|
+
function invalidSendContextError() {
|
|
77
|
+
const error = new errors_1.SubmitError(errors_1.SubmitResult.InvalidState, 0);
|
|
78
|
+
error.message = 'send is only valid for received routed message contexts';
|
|
79
|
+
return error;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A received message envelope: its routing metadata and message parts, plus an
|
|
83
|
+
* optional reply/send context.
|
|
84
|
+
*
|
|
85
|
+
* Owns its parts until closed. Reuse one instance across `recv` calls to avoid
|
|
86
|
+
* a per-receive allocation.
|
|
87
|
+
*/
|
|
88
|
+
class Received extends message_parts_envelope_1.MessagePartsEnvelope {
|
|
89
|
+
/** The source routing id, or null when the receive path provides none. */
|
|
90
|
+
routingId;
|
|
91
|
+
/** Opaque reply capability, present only for a ROUTER REQUEST receive. */
|
|
92
|
+
replyToken;
|
|
93
|
+
_replyContext;
|
|
94
|
+
_sendContext;
|
|
95
|
+
/** Create an empty reusable envelope for use with `recv`. */
|
|
96
|
+
constructor(...args) {
|
|
97
|
+
if (args.length > 0) {
|
|
98
|
+
throw new TypeError('Received reusable envelopes are created without constructor arguments');
|
|
99
|
+
}
|
|
100
|
+
super();
|
|
101
|
+
this.routingId = null;
|
|
102
|
+
this.replyToken = null;
|
|
103
|
+
this._replyContext = null;
|
|
104
|
+
this._sendContext = null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Begin a reply to this request: add parts on the returned builder, then
|
|
108
|
+
* submit. Parts are consumed on a successful submit. Throws when the envelope
|
|
109
|
+
* is not replyable (has no reply token).
|
|
110
|
+
*/
|
|
111
|
+
reply() {
|
|
112
|
+
if (!this.replyToken || !this._replyContext) {
|
|
113
|
+
throw invalidReplyContextError();
|
|
114
|
+
}
|
|
115
|
+
return this._replyContext.beginReply();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Begin a send addressed to this envelope's source route: add parts, then
|
|
119
|
+
* submit. Message ownership transfers on immediate admission or after the
|
|
120
|
+
* managed send takes its first back-pressure snapshot, before the Promise may
|
|
121
|
+
* resolve. Throws when the envelope carries no send context.
|
|
122
|
+
*/
|
|
123
|
+
send() {
|
|
124
|
+
if (!this._sendContext) {
|
|
125
|
+
throw invalidSendContextError();
|
|
126
|
+
}
|
|
127
|
+
return this._sendContext.beginSend();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.Received = Received;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RoutingId } from '../core';
|
|
2
|
+
import type { Message } from './message';
|
|
3
|
+
/** Reusable output storage for one STREAM packet. */
|
|
4
|
+
export declare class StreamPacket {
|
|
5
|
+
private _receiving;
|
|
6
|
+
private _routingId;
|
|
7
|
+
private _header;
|
|
8
|
+
private _body;
|
|
9
|
+
get isEmpty(): boolean;
|
|
10
|
+
get routingId(): RoutingId | null;
|
|
11
|
+
get header(): Message | null;
|
|
12
|
+
get body(): Message | null;
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.StreamPacket = void 0;
|
|
5
|
+
exports.streamPacketState = streamPacketState;
|
|
6
|
+
/** Reusable output storage for one STREAM packet. */
|
|
7
|
+
class StreamPacket {
|
|
8
|
+
_receiving = false;
|
|
9
|
+
_routingId = null;
|
|
10
|
+
_header = null;
|
|
11
|
+
_body = null;
|
|
12
|
+
get isEmpty() {
|
|
13
|
+
return !this._receiving
|
|
14
|
+
&& this._routingId === null
|
|
15
|
+
&& this._header === null
|
|
16
|
+
&& this._body === null;
|
|
17
|
+
}
|
|
18
|
+
get routingId() { return this._routingId; }
|
|
19
|
+
get header() { return this._header; }
|
|
20
|
+
get body() { return this._body; }
|
|
21
|
+
close() {
|
|
22
|
+
this._header?.close();
|
|
23
|
+
this._body?.close();
|
|
24
|
+
this._routingId = null;
|
|
25
|
+
this._header = null;
|
|
26
|
+
this._body = null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.StreamPacket = StreamPacket;
|
|
30
|
+
/** @internal */
|
|
31
|
+
function streamPacketState(packet) {
|
|
32
|
+
return packet;
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RoutingId } from '../core/routing_id';
|
|
2
|
+
/** A subscriber's subscribe or unsubscribe as observed by an XPUB socket. */
|
|
3
|
+
export declare class SubscriptionEvent {
|
|
4
|
+
/** The subscriber's routing id, or null when not known. */
|
|
5
|
+
routingId: RoutingId | null;
|
|
6
|
+
/** The topic that was subscribed or unsubscribed. */
|
|
7
|
+
topic: string;
|
|
8
|
+
/** True for a subscribe, false for an unsubscribe. */
|
|
9
|
+
subscribed: boolean;
|
|
10
|
+
/** Create an empty reusable event for use with `receiveSubscriptionEvent`. */
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SubscriptionEvent = void 0;
|
|
5
|
+
/** A subscriber's subscribe or unsubscribe as observed by an XPUB socket. */
|
|
6
|
+
class SubscriptionEvent {
|
|
7
|
+
/** The subscriber's routing id, or null when not known. */
|
|
8
|
+
routingId;
|
|
9
|
+
/** The topic that was subscribed or unsubscribed. */
|
|
10
|
+
topic;
|
|
11
|
+
/** True for a subscribe, false for an unsubscribe. */
|
|
12
|
+
subscribed;
|
|
13
|
+
/** Create an empty reusable event for use with `receiveSubscriptionEvent`. */
|
|
14
|
+
constructor() {
|
|
15
|
+
this.routingId = null;
|
|
16
|
+
this.topic = '';
|
|
17
|
+
this.subscribed = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.SubscriptionEvent = SubscriptionEvent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RoutingId } from '../core/routing_id';
|
|
2
|
+
import { MessagePartsEnvelope } from './message_parts_envelope';
|
|
3
|
+
/**
|
|
4
|
+
* A received publish: its topic and message parts. Owns its parts until closed.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TopicMessage extends MessagePartsEnvelope {
|
|
7
|
+
/** The source routing id, or null when the receive path provides none. */
|
|
8
|
+
routingId: RoutingId | null;
|
|
9
|
+
/** The topic the message was published under. */
|
|
10
|
+
topic: string;
|
|
11
|
+
/** Create an empty reusable envelope for use with `subscribe`. */
|
|
12
|
+
constructor();
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TopicMessage = void 0;
|
|
5
|
+
const message_parts_envelope_1 = require("./message_parts_envelope");
|
|
6
|
+
/**
|
|
7
|
+
* A received publish: its topic and message parts. Owns its parts until closed.
|
|
8
|
+
*/
|
|
9
|
+
class TopicMessage extends message_parts_envelope_1.MessagePartsEnvelope {
|
|
10
|
+
/** The source routing id, or null when the receive path provides none. */
|
|
11
|
+
routingId;
|
|
12
|
+
/** The topic the message was published under. */
|
|
13
|
+
topic;
|
|
14
|
+
/** @internal Single-part receive candidate, never exposed through parts. */
|
|
15
|
+
_reusableSinglePart;
|
|
16
|
+
/** @internal Frozen single-part views paired with reusable wrappers. */
|
|
17
|
+
_reusableSinglePartSlots;
|
|
18
|
+
/** Create an empty reusable envelope for use with `subscribe`. */
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.routingId = null;
|
|
22
|
+
this.topic = '';
|
|
23
|
+
this._reusableSinglePart = null;
|
|
24
|
+
this._reusableSinglePartSlots = [];
|
|
25
|
+
}
|
|
26
|
+
close() {
|
|
27
|
+
const candidate = this._reusableSinglePart;
|
|
28
|
+
super.close();
|
|
29
|
+
this._reusableSinglePart = null;
|
|
30
|
+
this._reusableSinglePartSlots = [];
|
|
31
|
+
if (candidate && !this.parts.includes(candidate)) {
|
|
32
|
+
candidate.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.TopicMessage = TopicMessage;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { RoutingId } from '../core';
|
|
2
|
+
import type { Received, RequestOperation, SendOperation } from '../messaging';
|
|
3
|
+
import type { RecvFlags } from './socket_constants';
|
|
4
|
+
import type { DealerSocketOptions } from './socket_options';
|
|
5
|
+
import type { ConnectableSocket } from './socket';
|
|
6
|
+
/**
|
|
7
|
+
* DEALER socket: load-balances sends across its connected peers and can issue
|
|
8
|
+
* routed requests.
|
|
9
|
+
*/
|
|
10
|
+
export interface DealerSocket extends ConnectableSocket {
|
|
11
|
+
/** The DEALER-specific typed options facade. */
|
|
12
|
+
readonly options: DealerSocketOptions;
|
|
13
|
+
/** Begin a managed send; `submit()` resolves after Core accepts the record. */
|
|
14
|
+
send(): SendOperation;
|
|
15
|
+
/** Receive a message into `result`; false for non-blocking no-data. */
|
|
16
|
+
recv(result: Received, flags?: RecvFlags): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Set the routing id that identifies this DEALER to its peers. Apply before
|
|
19
|
+
* connecting so peers observe it from the first message.
|
|
20
|
+
*/
|
|
21
|
+
setRoutingId(routingId: RoutingId): void;
|
|
22
|
+
/** Return the routing id that identifies this DEALER to its peers. */
|
|
23
|
+
getRoutingId(): RoutingId;
|
|
24
|
+
/**
|
|
25
|
+
* Begin a request: add parts on the returned builder, then submit and await a
|
|
26
|
+
* reply. Parts are consumed on a successful submit.
|
|
27
|
+
*/
|
|
28
|
+
request(): RequestOperation;
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { SocketType, SOCKET_MONITOR_EVENT_ALL, SendFlags, RecvFlags, CompletionKind, RidDuplicatePolicy, SubmitRetryMode, StreamRecvMode, PollEventFlag, ReceiveFlowState, } from './socket_constants';
|
|
2
|
+
export type { MonitorEventMask, SocketTypeValue, SendFlags as SendFlagsValue, RecvFlags as RecvFlagsValue, CompletionKind as CompletionKindValue, RidDuplicatePolicy as RidDuplicatePolicyValue, SubmitRetryMode as SubmitRetryModeValue, PollEventFlagValue, ReceiveFlowState as ReceiveFlowStateValue, } from './socket_constants';
|
|
3
|
+
export type { BaseSocket, ConnectableSocket, Socket, } from './socket';
|
|
4
|
+
export type { CommonSocketOptions, DealerSocketOptions, PubSocketOptions, RouterSocketOptions, StreamSocketOptions, SubSocketOptions, } from './socket_options';
|
|
5
|
+
export type * from '../messaging/operations';
|
|
6
|
+
export type { PairSocket } from './pair_socket';
|
|
7
|
+
export type { DealerSocket } from './dealer_socket';
|
|
8
|
+
export type { RouterSocket } from './router_socket';
|
|
9
|
+
export type { PubSocket, SubSocket, XPubSocket, XSubSocket, } from './pubsub_sockets';
|
|
10
|
+
export type { StreamSocket } from './stream_socket';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReceiveFlowState = exports.PollEventFlag = exports.StreamRecvMode = exports.SubmitRetryMode = exports.RidDuplicatePolicy = exports.CompletionKind = exports.RecvFlags = exports.SendFlags = exports.SOCKET_MONITOR_EVENT_ALL = exports.SocketType = void 0;
|
|
5
|
+
var socket_constants_1 = require("./socket_constants");
|
|
6
|
+
Object.defineProperty(exports, "SocketType", { enumerable: true, get: function () { return socket_constants_1.SocketType; } });
|
|
7
|
+
Object.defineProperty(exports, "SOCKET_MONITOR_EVENT_ALL", { enumerable: true, get: function () { return socket_constants_1.SOCKET_MONITOR_EVENT_ALL; } });
|
|
8
|
+
Object.defineProperty(exports, "SendFlags", { enumerable: true, get: function () { return socket_constants_1.SendFlags; } });
|
|
9
|
+
Object.defineProperty(exports, "RecvFlags", { enumerable: true, get: function () { return socket_constants_1.RecvFlags; } });
|
|
10
|
+
Object.defineProperty(exports, "CompletionKind", { enumerable: true, get: function () { return socket_constants_1.CompletionKind; } });
|
|
11
|
+
Object.defineProperty(exports, "RidDuplicatePolicy", { enumerable: true, get: function () { return socket_constants_1.RidDuplicatePolicy; } });
|
|
12
|
+
Object.defineProperty(exports, "SubmitRetryMode", { enumerable: true, get: function () { return socket_constants_1.SubmitRetryMode; } });
|
|
13
|
+
Object.defineProperty(exports, "StreamRecvMode", { enumerable: true, get: function () { return socket_constants_1.StreamRecvMode; } });
|
|
14
|
+
Object.defineProperty(exports, "PollEventFlag", { enumerable: true, get: function () { return socket_constants_1.PollEventFlag; } });
|
|
15
|
+
Object.defineProperty(exports, "ReceiveFlowState", { enumerable: true, get: function () { return socket_constants_1.ReceiveFlowState; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Received } from '../messaging';
|
|
2
|
+
import type { SendOperation } from '../messaging';
|
|
3
|
+
import type { RecvFlags } from './socket_constants';
|
|
4
|
+
import type { CommonSocketOptions } from './socket_options';
|
|
5
|
+
import type { ConnectableSocket } from './socket';
|
|
6
|
+
/** PAIR socket: an exclusive one-to-one peering with no routing. */
|
|
7
|
+
export interface PairSocket extends ConnectableSocket {
|
|
8
|
+
/** The typed options facade common to all socket types. */
|
|
9
|
+
readonly options: CommonSocketOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Begin a multipart send: add parts on the returned builder, then submit.
|
|
12
|
+
* Parts are consumed on a successful submit.
|
|
13
|
+
*/
|
|
14
|
+
send(): SendOperation;
|
|
15
|
+
/**
|
|
16
|
+
* Receive a message into `result`; return true on success, or false when
|
|
17
|
+
* `RecvFlags.DontWait` is set and no message is available.
|
|
18
|
+
*/
|
|
19
|
+
recv(result: Received, flags?: RecvFlags): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SubscriptionEvent, TopicMessage } from '../messaging';
|
|
2
|
+
import type { PublishOperation } from '../messaging';
|
|
3
|
+
import type { SubscriptionEntry } from '../messaging';
|
|
4
|
+
import type { RecvFlags } from './socket_constants';
|
|
5
|
+
import type { PubSocketOptions, SubSocketOptions } from './socket_options';
|
|
6
|
+
import type { ConnectableSocket } from './socket';
|
|
7
|
+
/** PUB socket: topic-filtered publish that drops messages with no matching subscriber. */
|
|
8
|
+
export interface PubSocket extends ConnectableSocket {
|
|
9
|
+
/** The PUB-specific typed options facade. */
|
|
10
|
+
readonly options: PubSocketOptions;
|
|
11
|
+
/** Begin synchronous lossy publishing under `topic`; submit is void-or-throw. */
|
|
12
|
+
publish(topic: string): PublishOperation;
|
|
13
|
+
}
|
|
14
|
+
/** XPUB socket: like PUB, but also surfaces subscriber subscription and unsubscription events. */
|
|
15
|
+
export interface XPubSocket extends PubSocket {
|
|
16
|
+
/**
|
|
17
|
+
* Receive the next subscriber (un)subscription event into `result`; false
|
|
18
|
+
* when `RecvFlags.DontWait` is set and none is available.
|
|
19
|
+
*/
|
|
20
|
+
receiveSubscriptionEvent(result: SubscriptionEvent, flags?: RecvFlags): boolean;
|
|
21
|
+
}
|
|
22
|
+
/** SUB socket: a receive-only subscriber filtered by its subscriptions. */
|
|
23
|
+
export interface SubSocket extends ConnectableSocket {
|
|
24
|
+
/** The SUB-specific typed options facade. */
|
|
25
|
+
readonly options: SubSocketOptions;
|
|
26
|
+
/** Add a subscription for `filter` (an exact topic or pattern); subscriptions accumulate. */
|
|
27
|
+
setSubscription(filter: string): void;
|
|
28
|
+
/** Remove a subscription previously added for `filter`. */
|
|
29
|
+
unsetSubscription(filter: string): void;
|
|
30
|
+
/** Return the active subscription at `index`, or null when out of range. */
|
|
31
|
+
subscriptionAt(index: number): SubscriptionEntry | null;
|
|
32
|
+
/**
|
|
33
|
+
* Receive the next matching topic message into `result`; false when
|
|
34
|
+
* `RecvFlags.DontWait` is set and none is available.
|
|
35
|
+
*/
|
|
36
|
+
subscribe(result: TopicMessage, flags?: RecvFlags): boolean;
|
|
37
|
+
}
|
|
38
|
+
/** XSUB socket: a subscriber whose subscriptions are carried as messages. */
|
|
39
|
+
export interface XSubSocket extends SubSocket {
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RoutingId } from '../core';
|
|
2
|
+
import type { Received, ReplyToken } from '../messaging';
|
|
3
|
+
import type { ReplyOperation, RequestOperation, SendOperation } from '../messaging';
|
|
4
|
+
import type { RecvFlags } from './socket_constants';
|
|
5
|
+
import type { RouterSocketOptions } from './socket_options';
|
|
6
|
+
import type { ConnectableSocket } from './socket';
|
|
7
|
+
/**
|
|
8
|
+
* ROUTER socket: routes messages to peers addressed by routing id, the server
|
|
9
|
+
* side of asynchronous request/reply.
|
|
10
|
+
*/
|
|
11
|
+
export interface RouterSocket extends ConnectableSocket {
|
|
12
|
+
/** The ROUTER-specific typed options facade. */
|
|
13
|
+
readonly options: RouterSocketOptions;
|
|
14
|
+
/** Begin a send addressed to `routingId`; parts are consumed on a successful submit. */
|
|
15
|
+
send(routingId: RoutingId): SendOperation;
|
|
16
|
+
/**
|
|
17
|
+
* Receive a routed message into `result`; false when `RecvFlags.DontWait` is
|
|
18
|
+
* set and no message is available.
|
|
19
|
+
*/
|
|
20
|
+
recv(result: Received, flags?: RecvFlags): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Set the routing id that identifies this ROUTER to its peers. Apply before
|
|
23
|
+
* connecting so peers observe it from the first message.
|
|
24
|
+
*/
|
|
25
|
+
setRoutingId(routingId: RoutingId): void;
|
|
26
|
+
/** Return the routing id that identifies this ROUTER to its peers. */
|
|
27
|
+
getRoutingId(): RoutingId;
|
|
28
|
+
/** Begin a request to peer `peerRid`; parts are consumed on submit and a reply is awaited. */
|
|
29
|
+
request(peerRid: RoutingId): RequestOperation;
|
|
30
|
+
/** Begin a reply using the opaque token returned by this ROUTER's request receive. */
|
|
31
|
+
reply(peerRid: RoutingId, token: ReplyToken): ReplyOperation;
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { MonitorEventType, MonitorSocket } from '../eventing';
|
|
2
|
+
import type { RoutingId } from '../core';
|
|
3
|
+
import type { ReceiveFlowState } from './socket_constants';
|
|
4
|
+
import type { DealerSocket } from './dealer_socket';
|
|
5
|
+
import type { PairSocket } from './pair_socket';
|
|
6
|
+
import type { PubSocket, SubSocket, XPubSocket, XSubSocket } from './pubsub_sockets';
|
|
7
|
+
import type { RouterSocket } from './router_socket';
|
|
8
|
+
import type { StreamSocket } from './stream_socket';
|
|
9
|
+
/** Base contract shared by every socket type: lifetime, binding, TLS, and monitoring. */
|
|
10
|
+
export interface Socket {
|
|
11
|
+
/**
|
|
12
|
+
* Bind to a local transport address (for example `tcp://*:5555`) to accept
|
|
13
|
+
* connections there.
|
|
14
|
+
*/
|
|
15
|
+
bind(endpoint: string): void;
|
|
16
|
+
/** Stop accepting connections at `endpoint`, a previously bound address. */
|
|
17
|
+
unbind(endpoint: string): void;
|
|
18
|
+
/** Close the socket and release its native resources. */
|
|
19
|
+
close(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Open a monitor reporting the selected lifecycle `events`. The caller owns
|
|
22
|
+
* the returned monitor and must close it.
|
|
23
|
+
*/
|
|
24
|
+
monitorOpen(events?: readonly MonitorEventType[], monitorHwmBytes?: bigint): MonitorSocket;
|
|
25
|
+
/**
|
|
26
|
+
* Configure this socket as a TLS server. Apply before binding. `cert`/`key`
|
|
27
|
+
* are PEM paths; `requireClientCert` requires mutual TLS.
|
|
28
|
+
*/
|
|
29
|
+
setTlsServer(cert: string, key: string, requireClientCert?: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* Configure this socket as a TLS client. Apply before connecting. `ca` is the
|
|
32
|
+
* CA bundle path, `hostname` the expected server hostname, and `trustSystem`
|
|
33
|
+
* also trusts the system CA store.
|
|
34
|
+
*/
|
|
35
|
+
setTlsClient(ca: string, hostname: string, trustSystem?: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* Set this socket's local receive-flow state. Only DEALER and ROUTER
|
|
38
|
+
* sockets support this; PAIR, the PUB/SUB family, and STREAM report
|
|
39
|
+
* `ConfigResult.NotSupported`. Setting the same state again succeeds
|
|
40
|
+
* (idempotent). This does not expose flow frames or any PAUSE-bypass send
|
|
41
|
+
* path; observe flow transitions only through the existing monitor and
|
|
42
|
+
* snapshot surfaces.
|
|
43
|
+
*/
|
|
44
|
+
setReceiveFlowState(state: ReceiveFlowState): void;
|
|
45
|
+
}
|
|
46
|
+
/** A socket that can also initiate outbound connections, not just bind. */
|
|
47
|
+
export interface ConnectableSocket extends Socket {
|
|
48
|
+
/**
|
|
49
|
+
* Connect to a remote transport address. Connection is asynchronous; this
|
|
50
|
+
* returns before the peer is reachable.
|
|
51
|
+
*/
|
|
52
|
+
connect(endpoint: string): void;
|
|
53
|
+
/** Disconnect the connection previously established to `endpoint`. */
|
|
54
|
+
disconnect(endpoint: string): void;
|
|
55
|
+
/** Disconnect the peer identified by `routingId` rather than by address. */
|
|
56
|
+
disconnectRid(routingId: RoutingId): void;
|
|
57
|
+
}
|
|
58
|
+
export type BaseSocket = PairSocket | PubSocket | SubSocket | DealerSocket | RouterSocket | XPubSocket | XSubSocket | StreamSocket;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** A socket's messaging pattern (PAIR, PUB, DEALER, ROUTER, STREAM, and so on). */
|
|
2
|
+
export declare const SocketType: Readonly<{
|
|
3
|
+
readonly ANY: 0;
|
|
4
|
+
readonly PAIR: 4097;
|
|
5
|
+
readonly PUB: 4098;
|
|
6
|
+
readonly SUB: 4099;
|
|
7
|
+
readonly DEALER: 4100;
|
|
8
|
+
readonly ROUTER: 4101;
|
|
9
|
+
readonly XPUB: 4102;
|
|
10
|
+
readonly XSUB: 4103;
|
|
11
|
+
readonly STREAM: 4104;
|
|
12
|
+
readonly Any: 0;
|
|
13
|
+
readonly Pair: 4097;
|
|
14
|
+
readonly Pub: 4098;
|
|
15
|
+
readonly Sub: 4099;
|
|
16
|
+
readonly Dealer: 4100;
|
|
17
|
+
readonly Router: 4101;
|
|
18
|
+
readonly XPub: 4102;
|
|
19
|
+
readonly XSub: 4103;
|
|
20
|
+
readonly Stream: 4104;
|
|
21
|
+
}>;
|
|
22
|
+
export type SocketTypeValue = typeof SocketType[keyof typeof SocketType];
|
|
23
|
+
/** A bitmask selecting which socket monitor events to subscribe to. */
|
|
24
|
+
export type MonitorEventMask = number;
|
|
25
|
+
/** Subscribe to every socket monitor event. */
|
|
26
|
+
export declare const SOCKET_MONITOR_EVENT_ALL = 524287;
|
|
27
|
+
/**
|
|
28
|
+
* A socket's local receive-flow state, applied to DEALER/ROUTER sockets via
|
|
29
|
+
* `setReceiveFlowState`. Values match `zlink_receive_flow_state_t`. Setting
|
|
30
|
+
* `PAUSED` synthesizes a remote-PAUSE condition for affected Application
|
|
31
|
+
* pipes; control uses the Application connection for count-1 peers and the
|
|
32
|
+
* Completion connection for count-2 ROUTER-ROUTER peers. Setting the same
|
|
33
|
+
* state again is a no-op success.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ReceiveFlowState: Readonly<{
|
|
36
|
+
readonly RUNNING: 0;
|
|
37
|
+
readonly PAUSED: 1;
|
|
38
|
+
}>;
|
|
39
|
+
export type ReceiveFlowState = typeof ReceiveFlowState[keyof typeof ReceiveFlowState];
|
|
40
|
+
/** Flags that modify send behavior; `DontWait` reports back-pressure instead of blocking. */
|
|
41
|
+
export declare const SendFlags: Readonly<{
|
|
42
|
+
readonly None: 0;
|
|
43
|
+
readonly DontWait: 1;
|
|
44
|
+
}>;
|
|
45
|
+
export type SendFlags = typeof SendFlags[keyof typeof SendFlags];
|
|
46
|
+
/** Flags that modify receive behavior; `DontWait` returns instead of blocking when no message is available. */
|
|
47
|
+
export declare const RecvFlags: Readonly<{
|
|
48
|
+
readonly None: 0;
|
|
49
|
+
readonly DontWait: 1;
|
|
50
|
+
}>;
|
|
51
|
+
export type RecvFlags = typeof RecvFlags[keyof typeof RecvFlags];
|
|
52
|
+
/** Kinds carried by socket-local Core completion records. */
|
|
53
|
+
export declare const CompletionKind: Readonly<{
|
|
54
|
+
readonly Send: 1;
|
|
55
|
+
readonly Request: 2;
|
|
56
|
+
readonly Writable: 3;
|
|
57
|
+
}>;
|
|
58
|
+
export type CompletionKind = typeof CompletionKind[keyof typeof CompletionKind];
|
|
59
|
+
/** How a socket reacts to a peer that reuses an existing routing id. */
|
|
60
|
+
export declare const RidDuplicatePolicy: Readonly<{
|
|
61
|
+
readonly Reject: 0;
|
|
62
|
+
readonly Handover: 1;
|
|
63
|
+
}>;
|
|
64
|
+
export type RidDuplicatePolicy = typeof RidDuplicatePolicy[keyof typeof RidDuplicatePolicy];
|
|
65
|
+
export type RidDuplicatePolicyValue = RidDuplicatePolicy;
|
|
66
|
+
/** Whether a failed submit is retried (`Off` or `LocalFailure`). */
|
|
67
|
+
export declare const SubmitRetryMode: Readonly<{
|
|
68
|
+
readonly Off: 0;
|
|
69
|
+
readonly LocalFailure: 1;
|
|
70
|
+
}>;
|
|
71
|
+
export type SubmitRetryMode = typeof SubmitRetryMode[keyof typeof SubmitRetryMode];
|
|
72
|
+
export type SubmitRetryModeValue = SubmitRetryMode;
|
|
73
|
+
/** STREAM receive representation. Unspecified cannot be assigned by callers. */
|
|
74
|
+
export declare const StreamRecvMode: Readonly<{
|
|
75
|
+
readonly Unspecified: 0;
|
|
76
|
+
readonly Raw: 1;
|
|
77
|
+
readonly Packet: 2;
|
|
78
|
+
}>;
|
|
79
|
+
export type StreamRecvMode = typeof StreamRecvMode[keyof typeof StreamRecvMode];
|
|
80
|
+
/** Readiness conditions a poll source can be watched for or report (readable, writable, error). */
|
|
81
|
+
export declare const PollEventFlag: Readonly<{
|
|
82
|
+
readonly PollIn: 1;
|
|
83
|
+
readonly PollOut: 2;
|
|
84
|
+
readonly PollErr: 4;
|
|
85
|
+
readonly PollPri: 8;
|
|
86
|
+
readonly PollCompletion: 32;
|
|
87
|
+
}>;
|
|
88
|
+
export type PollEventFlagValue = typeof PollEventFlag[keyof typeof PollEventFlag];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PollEventFlag = exports.StreamRecvMode = exports.SubmitRetryMode = exports.RidDuplicatePolicy = exports.CompletionKind = exports.RecvFlags = exports.SendFlags = exports.ReceiveFlowState = exports.SOCKET_MONITOR_EVENT_ALL = exports.SocketType = void 0;
|
|
5
|
+
/** A socket's messaging pattern (PAIR, PUB, DEALER, ROUTER, STREAM, and so on). */
|
|
6
|
+
exports.SocketType = Object.freeze({
|
|
7
|
+
ANY: 0,
|
|
8
|
+
PAIR: 0x1001, PUB: 0x1002, SUB: 0x1003, DEALER: 0x1004,
|
|
9
|
+
ROUTER: 0x1005, XPUB: 0x1006, XSUB: 0x1007, STREAM: 0x1008,
|
|
10
|
+
Any: 0,
|
|
11
|
+
Pair: 0x1001,
|
|
12
|
+
Pub: 0x1002,
|
|
13
|
+
Sub: 0x1003,
|
|
14
|
+
Dealer: 0x1004,
|
|
15
|
+
Router: 0x1005,
|
|
16
|
+
XPub: 0x1006,
|
|
17
|
+
XSub: 0x1007,
|
|
18
|
+
Stream: 0x1008
|
|
19
|
+
});
|
|
20
|
+
/** Subscribe to every socket monitor event. */
|
|
21
|
+
exports.SOCKET_MONITOR_EVENT_ALL = 0x7FFFF;
|
|
22
|
+
/**
|
|
23
|
+
* A socket's local receive-flow state, applied to DEALER/ROUTER sockets via
|
|
24
|
+
* `setReceiveFlowState`. Values match `zlink_receive_flow_state_t`. Setting
|
|
25
|
+
* `PAUSED` synthesizes a remote-PAUSE condition for affected Application
|
|
26
|
+
* pipes; control uses the Application connection for count-1 peers and the
|
|
27
|
+
* Completion connection for count-2 ROUTER-ROUTER peers. Setting the same
|
|
28
|
+
* state again is a no-op success.
|
|
29
|
+
*/
|
|
30
|
+
exports.ReceiveFlowState = Object.freeze({
|
|
31
|
+
RUNNING: 0,
|
|
32
|
+
PAUSED: 1
|
|
33
|
+
});
|
|
34
|
+
/** Flags that modify send behavior; `DontWait` reports back-pressure instead of blocking. */
|
|
35
|
+
exports.SendFlags = Object.freeze({ None: 0, DontWait: 0x0001 });
|
|
36
|
+
/** Flags that modify receive behavior; `DontWait` returns instead of blocking when no message is available. */
|
|
37
|
+
exports.RecvFlags = Object.freeze({ None: 0, DontWait: 0x0001 });
|
|
38
|
+
/** Kinds carried by socket-local Core completion records. */
|
|
39
|
+
exports.CompletionKind = Object.freeze({
|
|
40
|
+
Send: 1,
|
|
41
|
+
Request: 2,
|
|
42
|
+
Writable: 3
|
|
43
|
+
});
|
|
44
|
+
/** How a socket reacts to a peer that reuses an existing routing id. */
|
|
45
|
+
exports.RidDuplicatePolicy = Object.freeze({
|
|
46
|
+
Reject: 0,
|
|
47
|
+
Handover: 1
|
|
48
|
+
});
|
|
49
|
+
/** Whether a failed submit is retried (`Off` or `LocalFailure`). */
|
|
50
|
+
exports.SubmitRetryMode = Object.freeze({
|
|
51
|
+
Off: 0,
|
|
52
|
+
LocalFailure: 1
|
|
53
|
+
});
|
|
54
|
+
/** STREAM receive representation. Unspecified cannot be assigned by callers. */
|
|
55
|
+
exports.StreamRecvMode = Object.freeze({
|
|
56
|
+
Unspecified: 0,
|
|
57
|
+
Raw: 1,
|
|
58
|
+
Packet: 2
|
|
59
|
+
});
|
|
60
|
+
/** Readiness conditions a poll source can be watched for or report (readable, writable, error). */
|
|
61
|
+
exports.PollEventFlag = Object.freeze({
|
|
62
|
+
PollIn: 1,
|
|
63
|
+
PollOut: 2,
|
|
64
|
+
PollErr: 4,
|
|
65
|
+
PollPri: 8,
|
|
66
|
+
PollCompletion: 32
|
|
67
|
+
});
|