@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,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ConfigError = exports.ConnectError = exports.BindError = exports.CloseError = exports.HandlerError = exports.RecvError = exports.RequestError = exports.SubmitError = exports.ZlinkError = exports.SubmitResult = exports.RequestResult = exports.RecvResult = exports.HandlerResult = exports.ConnectResult = exports.ConfigResult = exports.CloseResult = exports.BindResult = void 0;
|
|
5
|
+
var results_1 = require("./results");
|
|
6
|
+
Object.defineProperty(exports, "BindResult", { enumerable: true, get: function () { return results_1.BindResult; } });
|
|
7
|
+
Object.defineProperty(exports, "CloseResult", { enumerable: true, get: function () { return results_1.CloseResult; } });
|
|
8
|
+
Object.defineProperty(exports, "ConfigResult", { enumerable: true, get: function () { return results_1.ConfigResult; } });
|
|
9
|
+
Object.defineProperty(exports, "ConnectResult", { enumerable: true, get: function () { return results_1.ConnectResult; } });
|
|
10
|
+
Object.defineProperty(exports, "HandlerResult", { enumerable: true, get: function () { return results_1.HandlerResult; } });
|
|
11
|
+
Object.defineProperty(exports, "RecvResult", { enumerable: true, get: function () { return results_1.RecvResult; } });
|
|
12
|
+
Object.defineProperty(exports, "RequestResult", { enumerable: true, get: function () { return results_1.RequestResult; } });
|
|
13
|
+
Object.defineProperty(exports, "SubmitResult", { enumerable: true, get: function () { return results_1.SubmitResult; } });
|
|
14
|
+
/** Base class for all errors thrown by the zlink bindings; carries a result `code` and the underlying native errno. */
|
|
15
|
+
class ZlinkError extends Error {
|
|
16
|
+
code;
|
|
17
|
+
nativeErrno;
|
|
18
|
+
constructor(code, nativeErrno = 0) {
|
|
19
|
+
super(`zlink error ${code}`);
|
|
20
|
+
this.name = 'ZlinkError';
|
|
21
|
+
this.code = code | 0;
|
|
22
|
+
this.nativeErrno = nativeErrno | 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ZlinkError = ZlinkError;
|
|
26
|
+
class ResultError extends ZlinkError {
|
|
27
|
+
result;
|
|
28
|
+
constructor(name, result, nativeErrno = 0) {
|
|
29
|
+
super(result, nativeErrno);
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.result = result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Thrown when submitting a send or publish fails. */
|
|
35
|
+
class SubmitError extends ResultError {
|
|
36
|
+
constructor(result, nativeErrno = 0) {
|
|
37
|
+
super('SubmitError', result, nativeErrno);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.SubmitError = SubmitError;
|
|
41
|
+
/** Thrown when a request fails or its reply reports an error. */
|
|
42
|
+
class RequestError extends ResultError {
|
|
43
|
+
constructor(result, nativeErrno = 0) {
|
|
44
|
+
super('RequestError', result, nativeErrno);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.RequestError = RequestError;
|
|
48
|
+
/** Thrown when receiving a message fails. */
|
|
49
|
+
class RecvError extends ResultError {
|
|
50
|
+
constructor(result, nativeErrno = 0) {
|
|
51
|
+
super('RecvError', result, nativeErrno);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.RecvError = RecvError;
|
|
55
|
+
/** Thrown when registering or running a callback handler fails. */
|
|
56
|
+
class HandlerError extends ResultError {
|
|
57
|
+
constructor(result, nativeErrno = 0) {
|
|
58
|
+
super('HandlerError', result, nativeErrno);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.HandlerError = HandlerError;
|
|
62
|
+
/** Thrown when closing a socket or resource fails. */
|
|
63
|
+
class CloseError extends ResultError {
|
|
64
|
+
constructor(result, nativeErrno = 0) {
|
|
65
|
+
super('CloseError', result, nativeErrno);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.CloseError = CloseError;
|
|
69
|
+
/** Thrown when binding a socket to an endpoint fails. */
|
|
70
|
+
class BindError extends ResultError {
|
|
71
|
+
constructor(result, nativeErrno = 0) {
|
|
72
|
+
super('BindError', result, nativeErrno);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.BindError = BindError;
|
|
76
|
+
/** Thrown when connecting a socket to an endpoint fails. */
|
|
77
|
+
class ConnectError extends ResultError {
|
|
78
|
+
constructor(result, nativeErrno = 0) {
|
|
79
|
+
super('ConnectError', result, nativeErrno);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.ConnectError = ConnectError;
|
|
83
|
+
/** Thrown when reading or applying a configuration option fails. */
|
|
84
|
+
class ConfigError extends ResultError {
|
|
85
|
+
constructor(result, nativeErrno = 0) {
|
|
86
|
+
super('ConfigError', result, nativeErrno);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.ConfigError = ConfigError;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ConfigError = exports.ConnectError = exports.BindError = exports.CloseError = exports.HandlerError = exports.RecvError = exports.RequestError = exports.SubmitError = exports.ZlinkError = void 0;
|
|
19
|
+
var errors_1 = require("./errors");
|
|
20
|
+
Object.defineProperty(exports, "ZlinkError", { enumerable: true, get: function () { return errors_1.ZlinkError; } });
|
|
21
|
+
Object.defineProperty(exports, "SubmitError", { enumerable: true, get: function () { return errors_1.SubmitError; } });
|
|
22
|
+
Object.defineProperty(exports, "RequestError", { enumerable: true, get: function () { return errors_1.RequestError; } });
|
|
23
|
+
Object.defineProperty(exports, "RecvError", { enumerable: true, get: function () { return errors_1.RecvError; } });
|
|
24
|
+
Object.defineProperty(exports, "HandlerError", { enumerable: true, get: function () { return errors_1.HandlerError; } });
|
|
25
|
+
Object.defineProperty(exports, "CloseError", { enumerable: true, get: function () { return errors_1.CloseError; } });
|
|
26
|
+
Object.defineProperty(exports, "BindError", { enumerable: true, get: function () { return errors_1.BindError; } });
|
|
27
|
+
Object.defineProperty(exports, "ConnectError", { enumerable: true, get: function () { return errors_1.ConnectError; } });
|
|
28
|
+
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
|
|
29
|
+
__exportStar(require("./results"), exports);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** The outcome of submitting a send or publish. */
|
|
2
|
+
export declare const SubmitResult: Readonly<{
|
|
3
|
+
readonly Ok: 0;
|
|
4
|
+
readonly Backpressured: 1;
|
|
5
|
+
readonly NotConnected: 2;
|
|
6
|
+
readonly NotFound: 3;
|
|
7
|
+
readonly Terminated: 4;
|
|
8
|
+
readonly InvalidHandle: 5;
|
|
9
|
+
readonly InvalidArgument: 6;
|
|
10
|
+
readonly NotSupported: 7;
|
|
11
|
+
readonly InvalidState: 8;
|
|
12
|
+
readonly ThreadViolation: 9;
|
|
13
|
+
readonly OutOfMemory: 10;
|
|
14
|
+
readonly SeqExhausted: 11;
|
|
15
|
+
readonly InternalError: 12;
|
|
16
|
+
readonly NotAdmitted: 13;
|
|
17
|
+
}>;
|
|
18
|
+
export type SubmitResult = typeof SubmitResult[keyof typeof SubmitResult];
|
|
19
|
+
/** The terminal outcome of a request completion. */
|
|
20
|
+
export declare const RequestResult: Readonly<{
|
|
21
|
+
readonly Ok: 0;
|
|
22
|
+
readonly TimedOut: 101;
|
|
23
|
+
readonly NotFound: 102;
|
|
24
|
+
readonly Terminated: 103;
|
|
25
|
+
readonly ProtocolError: 104;
|
|
26
|
+
readonly InternalError: 105;
|
|
27
|
+
readonly Rejected: 106;
|
|
28
|
+
readonly Conflict: 107;
|
|
29
|
+
readonly Busy: 108;
|
|
30
|
+
readonly NotConnected: 109;
|
|
31
|
+
readonly InvalidArgument: 110;
|
|
32
|
+
readonly InvalidState: 111;
|
|
33
|
+
readonly NotSupported: 112;
|
|
34
|
+
readonly Backpressured: 113;
|
|
35
|
+
}>;
|
|
36
|
+
export type RequestResult = typeof RequestResult[keyof typeof RequestResult];
|
|
37
|
+
/** The outcome of a receive. */
|
|
38
|
+
export declare const RecvResult: Readonly<{
|
|
39
|
+
readonly Ok: 0;
|
|
40
|
+
readonly NoData: 201;
|
|
41
|
+
readonly Busy: 202;
|
|
42
|
+
readonly Terminated: 203;
|
|
43
|
+
readonly InvalidHandle: 204;
|
|
44
|
+
readonly NotSupported: 205;
|
|
45
|
+
readonly InternalError: 206;
|
|
46
|
+
readonly BufferTooSmall: 207;
|
|
47
|
+
readonly InvalidState: 208;
|
|
48
|
+
}>;
|
|
49
|
+
export type RecvResult = typeof RecvResult[keyof typeof RecvResult];
|
|
50
|
+
/** The outcome of registering or running a callback handler. */
|
|
51
|
+
export declare const HandlerResult: Readonly<{
|
|
52
|
+
readonly Ok: 0;
|
|
53
|
+
readonly InvalidArgument: 301;
|
|
54
|
+
readonly Busy: 302;
|
|
55
|
+
readonly NotSupported: 303;
|
|
56
|
+
readonly Deadlock: 304;
|
|
57
|
+
readonly InvalidHandle: 305;
|
|
58
|
+
readonly InternalError: 306;
|
|
59
|
+
}>;
|
|
60
|
+
export type HandlerResult = typeof HandlerResult[keyof typeof HandlerResult];
|
|
61
|
+
/** The outcome of closing a socket or resource. */
|
|
62
|
+
export declare const CloseResult: Readonly<{
|
|
63
|
+
readonly Ok: 0;
|
|
64
|
+
readonly Busy: 401;
|
|
65
|
+
readonly Shutdown: 402;
|
|
66
|
+
readonly InvalidHandle: 403;
|
|
67
|
+
readonly InternalError: 404;
|
|
68
|
+
}>;
|
|
69
|
+
export type CloseResult = typeof CloseResult[keyof typeof CloseResult];
|
|
70
|
+
/** The outcome of binding to an endpoint. */
|
|
71
|
+
export declare const BindResult: Readonly<{
|
|
72
|
+
readonly Ok: 0;
|
|
73
|
+
readonly InvalidArgument: 501;
|
|
74
|
+
readonly AddrInUse: 502;
|
|
75
|
+
readonly NotSupported: 503;
|
|
76
|
+
readonly InvalidHandle: 504;
|
|
77
|
+
readonly InternalError: 505;
|
|
78
|
+
}>;
|
|
79
|
+
export type BindResult = typeof BindResult[keyof typeof BindResult];
|
|
80
|
+
/** The outcome of connecting to an endpoint. */
|
|
81
|
+
export declare const ConnectResult: Readonly<{
|
|
82
|
+
readonly Ok: 0;
|
|
83
|
+
readonly InvalidArgument: 601;
|
|
84
|
+
readonly NotSupported: 602;
|
|
85
|
+
readonly InvalidHandle: 603;
|
|
86
|
+
readonly InternalError: 604;
|
|
87
|
+
readonly NotFound: 605;
|
|
88
|
+
readonly Conflict: 606;
|
|
89
|
+
readonly Busy: 607;
|
|
90
|
+
readonly AuthFailed: 608;
|
|
91
|
+
}>;
|
|
92
|
+
export type ConnectResult = typeof ConnectResult[keyof typeof ConnectResult];
|
|
93
|
+
/** The outcome of reading or applying a configuration option. */
|
|
94
|
+
export declare const ConfigResult: Readonly<{
|
|
95
|
+
readonly Ok: 0;
|
|
96
|
+
readonly InvalidHandle: 701;
|
|
97
|
+
readonly InvalidArgument: 702;
|
|
98
|
+
readonly NotSupported: 703;
|
|
99
|
+
readonly InternalError: 704;
|
|
100
|
+
readonly InvalidState: 705;
|
|
101
|
+
readonly NotFound: 706;
|
|
102
|
+
readonly Conflict: 707;
|
|
103
|
+
readonly BufferTooSmall: 708;
|
|
104
|
+
readonly Busy: 709;
|
|
105
|
+
}>;
|
|
106
|
+
export type ConfigResult = typeof ConfigResult[keyof typeof ConfigResult];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ConfigResult = exports.ConnectResult = exports.BindResult = exports.CloseResult = exports.HandlerResult = exports.RecvResult = exports.RequestResult = exports.SubmitResult = void 0;
|
|
5
|
+
/** The outcome of submitting a send or publish. */
|
|
6
|
+
exports.SubmitResult = Object.freeze({
|
|
7
|
+
Ok: 0,
|
|
8
|
+
Backpressured: 1,
|
|
9
|
+
NotConnected: 2,
|
|
10
|
+
NotFound: 3,
|
|
11
|
+
Terminated: 4,
|
|
12
|
+
InvalidHandle: 5,
|
|
13
|
+
InvalidArgument: 6,
|
|
14
|
+
NotSupported: 7,
|
|
15
|
+
InvalidState: 8,
|
|
16
|
+
ThreadViolation: 9,
|
|
17
|
+
OutOfMemory: 10,
|
|
18
|
+
SeqExhausted: 11,
|
|
19
|
+
InternalError: 12,
|
|
20
|
+
NotAdmitted: 13
|
|
21
|
+
});
|
|
22
|
+
/** The terminal outcome of a request completion. */
|
|
23
|
+
exports.RequestResult = Object.freeze({
|
|
24
|
+
Ok: 0,
|
|
25
|
+
TimedOut: 101,
|
|
26
|
+
NotFound: 102,
|
|
27
|
+
Terminated: 103,
|
|
28
|
+
ProtocolError: 104,
|
|
29
|
+
InternalError: 105,
|
|
30
|
+
Rejected: 106,
|
|
31
|
+
Conflict: 107,
|
|
32
|
+
Busy: 108,
|
|
33
|
+
NotConnected: 109,
|
|
34
|
+
InvalidArgument: 110,
|
|
35
|
+
InvalidState: 111,
|
|
36
|
+
NotSupported: 112,
|
|
37
|
+
Backpressured: 113
|
|
38
|
+
});
|
|
39
|
+
/** The outcome of a receive. */
|
|
40
|
+
exports.RecvResult = Object.freeze({
|
|
41
|
+
Ok: 0,
|
|
42
|
+
NoData: 201,
|
|
43
|
+
Busy: 202,
|
|
44
|
+
Terminated: 203,
|
|
45
|
+
InvalidHandle: 204,
|
|
46
|
+
NotSupported: 205,
|
|
47
|
+
InternalError: 206,
|
|
48
|
+
BufferTooSmall: 207,
|
|
49
|
+
InvalidState: 208
|
|
50
|
+
});
|
|
51
|
+
/** The outcome of registering or running a callback handler. */
|
|
52
|
+
exports.HandlerResult = Object.freeze({
|
|
53
|
+
Ok: 0,
|
|
54
|
+
InvalidArgument: 301,
|
|
55
|
+
Busy: 302,
|
|
56
|
+
NotSupported: 303,
|
|
57
|
+
Deadlock: 304,
|
|
58
|
+
InvalidHandle: 305,
|
|
59
|
+
InternalError: 306
|
|
60
|
+
});
|
|
61
|
+
/** The outcome of closing a socket or resource. */
|
|
62
|
+
exports.CloseResult = Object.freeze({
|
|
63
|
+
Ok: 0,
|
|
64
|
+
Busy: 401,
|
|
65
|
+
Shutdown: 402,
|
|
66
|
+
InvalidHandle: 403,
|
|
67
|
+
InternalError: 404
|
|
68
|
+
});
|
|
69
|
+
/** The outcome of binding to an endpoint. */
|
|
70
|
+
exports.BindResult = Object.freeze({
|
|
71
|
+
Ok: 0,
|
|
72
|
+
InvalidArgument: 501,
|
|
73
|
+
AddrInUse: 502,
|
|
74
|
+
NotSupported: 503,
|
|
75
|
+
InvalidHandle: 504,
|
|
76
|
+
InternalError: 505
|
|
77
|
+
});
|
|
78
|
+
/** The outcome of connecting to an endpoint. */
|
|
79
|
+
exports.ConnectResult = Object.freeze({
|
|
80
|
+
Ok: 0,
|
|
81
|
+
InvalidArgument: 601,
|
|
82
|
+
NotSupported: 602,
|
|
83
|
+
InvalidHandle: 603,
|
|
84
|
+
InternalError: 604,
|
|
85
|
+
NotFound: 605,
|
|
86
|
+
Conflict: 606,
|
|
87
|
+
Busy: 607,
|
|
88
|
+
AuthFailed: 608
|
|
89
|
+
});
|
|
90
|
+
/** The outcome of reading or applying a configuration option. */
|
|
91
|
+
exports.ConfigResult = Object.freeze({
|
|
92
|
+
Ok: 0,
|
|
93
|
+
InvalidHandle: 701,
|
|
94
|
+
InvalidArgument: 702,
|
|
95
|
+
NotSupported: 703,
|
|
96
|
+
InternalError: 704,
|
|
97
|
+
InvalidState: 705,
|
|
98
|
+
NotFound: 706,
|
|
99
|
+
Conflict: 707,
|
|
100
|
+
BufferTooSmall: 708,
|
|
101
|
+
Busy: 709
|
|
102
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./monitor"), exports);
|
|
19
|
+
__exportStar(require("./poller"), exports);
|
|
20
|
+
__exportStar(require("./timer"), exports);
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { RoutingId } from '../core';
|
|
2
|
+
/** Identifies what a monitored source is. The Core raw API defines only the socket source. */
|
|
3
|
+
export declare const MonitorSourceKind: Readonly<{
|
|
4
|
+
readonly Socket: 1;
|
|
5
|
+
}>;
|
|
6
|
+
export type MonitorSourceKindValue = typeof MonitorSourceKind[keyof typeof MonitorSourceKind];
|
|
7
|
+
/** The kind of a delivered socket monitor connection-lifecycle event. */
|
|
8
|
+
export declare const MonitorEventType: Readonly<{
|
|
9
|
+
readonly Connected: 1;
|
|
10
|
+
readonly ConnectDelayed: 2;
|
|
11
|
+
readonly ConnectRetried: 4;
|
|
12
|
+
readonly Listening: 8;
|
|
13
|
+
readonly BindFailed: 16;
|
|
14
|
+
readonly Accepted: 32;
|
|
15
|
+
readonly AcceptFailed: 64;
|
|
16
|
+
readonly Closed: 128;
|
|
17
|
+
readonly CloseFailed: 256;
|
|
18
|
+
readonly Disconnected: 512;
|
|
19
|
+
readonly MonitorStopped: 1024;
|
|
20
|
+
readonly HandshakeFailedNoDetail: 2048;
|
|
21
|
+
readonly ConnectionReady: 4096;
|
|
22
|
+
readonly HandshakeFailedProtocol: 8192;
|
|
23
|
+
readonly HandshakeFailedAuth: 16384;
|
|
24
|
+
readonly PeerWeightChanged: 32768;
|
|
25
|
+
/** A remote-PAUSE condition was first applied to an affected application pipe. */
|
|
26
|
+
readonly SendFlowPaused: 65536;
|
|
27
|
+
/** A remote-PAUSE condition was cleared on an affected application pipe. */
|
|
28
|
+
readonly SendFlowResumed: 131072;
|
|
29
|
+
/** A stale or duplicate receive-flow-state frame (old generation or non-advancing epoch) was ignored. */
|
|
30
|
+
readonly FlowStateStale: 262144;
|
|
31
|
+
}>;
|
|
32
|
+
export type MonitorEventType = typeof MonitorEventType[keyof typeof MonitorEventType];
|
|
33
|
+
/**
|
|
34
|
+
* Bits carried in `MonitorEvent.flags`. Values match
|
|
35
|
+
* `ZLINK_MONITOR_EVENT_FLAG_*` in `zlink/eventing/api.h`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MonitorEventFlag: Readonly<{
|
|
38
|
+
/** Set on `ConnectionReady` when the connection changed from not-ready to ready. */
|
|
39
|
+
readonly ConnectionReadyEdge: 1;
|
|
40
|
+
/**
|
|
41
|
+
* Set on `SendFlowResumed` when clearing the remote pause left the pipe
|
|
42
|
+
* actually writable. `value` carries the flow epoch.
|
|
43
|
+
*/
|
|
44
|
+
readonly SendFlowWritable: 2;
|
|
45
|
+
/**
|
|
46
|
+
* Set on `FlowStateStale` when the frame named a different connection
|
|
47
|
+
* generation. `value` carries the received generation.
|
|
48
|
+
*/
|
|
49
|
+
readonly FlowStateStaleGeneration: 4;
|
|
50
|
+
/**
|
|
51
|
+
* Set on `FlowStateStale` when the epoch did not advance inside the
|
|
52
|
+
* current generation. `value` carries the received epoch.
|
|
53
|
+
*/
|
|
54
|
+
readonly FlowStateStaleEpoch: 8;
|
|
55
|
+
}>;
|
|
56
|
+
export type MonitorEventFlag = typeof MonitorEventFlag[keyof typeof MonitorEventFlag];
|
|
57
|
+
/**
|
|
58
|
+
* A snapshot of a monitored socket's state and auto-high-water-mark telemetry.
|
|
59
|
+
*
|
|
60
|
+
* `sourceKind` identifies the monitored source; `stateFlags`/`detailFlags` are
|
|
61
|
+
* bit masks of its current state; `snd/rcvPendingMsgs` and
|
|
62
|
+
* `snd/rcvPendingBytes` are queued message and byte counts;
|
|
63
|
+
* counts; and the `autoHwm*` fields report the automatic high-water-mark sizing
|
|
64
|
+
* decisions (applied marks, effective buffers, last recalculation, deferred
|
|
65
|
+
* shrinks).
|
|
66
|
+
*/
|
|
67
|
+
export interface MonitorStatus {
|
|
68
|
+
readonly abiVersion: number;
|
|
69
|
+
readonly structSize: number;
|
|
70
|
+
readonly sourceKind: MonitorSourceKindValue;
|
|
71
|
+
readonly stateFlags: number;
|
|
72
|
+
readonly detailFlags: number;
|
|
73
|
+
readonly sndPendingMsgs: bigint;
|
|
74
|
+
readonly rcvPendingMsgs: bigint;
|
|
75
|
+
readonly sndPendingBytes: bigint;
|
|
76
|
+
readonly rcvPendingBytes: bigint;
|
|
77
|
+
readonly autoHwmEnabled: boolean;
|
|
78
|
+
readonly autoHwmProfile: number;
|
|
79
|
+
readonly autoHwmRole: number;
|
|
80
|
+
readonly autoHwmPolicyClass: number;
|
|
81
|
+
readonly autoHwmPlannedSndHwmBytes: bigint;
|
|
82
|
+
readonly autoHwmPlannedRcvHwmBytes: bigint;
|
|
83
|
+
readonly autoHwmAppliedSndHwmBytes: bigint;
|
|
84
|
+
readonly autoHwmAppliedRcvHwmBytes: bigint;
|
|
85
|
+
readonly autoHwmEffectiveSndBuf: number;
|
|
86
|
+
readonly autoHwmEffectiveRcvBuf: number;
|
|
87
|
+
readonly autoHwmLastRecalcMs: bigint;
|
|
88
|
+
readonly autoHwmLastRecalcReason: number;
|
|
89
|
+
readonly autoHwmSendBlockedRatioPpm: number;
|
|
90
|
+
readonly autoHwmDeferredSndHwmBytes: bigint;
|
|
91
|
+
readonly autoHwmDeferredRcvHwmBytes: bigint;
|
|
92
|
+
readonly autoHwmDeferredSndHwmValid: boolean;
|
|
93
|
+
readonly autoHwmDeferredRcvHwmValid: boolean;
|
|
94
|
+
readonly sndBytesInFlight: bigint;
|
|
95
|
+
readonly rcvBytesInFlight: bigint;
|
|
96
|
+
readonly minimumCoreMessageChargeBytes: bigint;
|
|
97
|
+
readonly oversizeMessageAdmissionCount: bigint;
|
|
98
|
+
readonly oversizeMessageAdmissionMaxBytes: bigint;
|
|
99
|
+
/**
|
|
100
|
+
* DEALER/ROUTER receive-flow telemetry for affected application pipes
|
|
101
|
+
* (present since ABI 4). Populated only for DEALER/ROUTER sockets; other socket
|
|
102
|
+
* types report zero for all five fields.
|
|
103
|
+
*/
|
|
104
|
+
/** Current count of application pipes this socket sees as remote-PAUSED. */
|
|
105
|
+
readonly flowPausedConnections: bigint;
|
|
106
|
+
/** Total PAUSED transitions actually applied (never a stale/duplicate). */
|
|
107
|
+
readonly flowPauseAppliedTotal: bigint;
|
|
108
|
+
/** Total RUNNING transitions actually applied (never a stale/duplicate). */
|
|
109
|
+
readonly flowResumeAppliedTotal: bigint;
|
|
110
|
+
/** Total stale or duplicate flow-state frames ignored. */
|
|
111
|
+
readonly flowStateStaleTotal: bigint;
|
|
112
|
+
/** Duration of the most recently completed PAUSED interval, in milliseconds. 0 if none has completed yet. */
|
|
113
|
+
readonly flowPauseDurationMs: bigint;
|
|
114
|
+
/** Whether the monitored socket is in the ready state. */
|
|
115
|
+
isReady(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Whether `flowPausedConnections` and the other `flow*` fields are
|
|
118
|
+
* populated (ABI 4+, paired DEALER/ROUTER sockets only). Mirrors
|
|
119
|
+
* `ZLINK_MONITOR_STATUS_DETAIL_FLOW_STATE` in `zlink_enum.h`.
|
|
120
|
+
*/
|
|
121
|
+
isFlowStateDetailPopulated(): boolean;
|
|
122
|
+
}
|
|
123
|
+
/** A single socket connection-lifecycle event reported by a monitor. */
|
|
124
|
+
export declare class MonitorEvent {
|
|
125
|
+
/** The kind of lifecycle event. */
|
|
126
|
+
readonly event: MonitorEventType;
|
|
127
|
+
/**
|
|
128
|
+
* An event-specific value, such as an error code, reconnect interval, or
|
|
129
|
+
* (for the flow events) a generation/epoch counter. A full 64-bit unsigned
|
|
130
|
+
* value; use `bigint` arithmetic to read it losslessly.
|
|
131
|
+
*/
|
|
132
|
+
readonly value: bigint;
|
|
133
|
+
/** The peer routing id, or null when the event carries none. */
|
|
134
|
+
readonly routingId: RoutingId | null;
|
|
135
|
+
/** The local endpoint address. */
|
|
136
|
+
readonly localAddr: string;
|
|
137
|
+
/** The remote endpoint address. */
|
|
138
|
+
readonly remoteAddr: string;
|
|
139
|
+
/** Process-local identity of the physical transport attempt. */
|
|
140
|
+
readonly connectionId: bigint;
|
|
141
|
+
/** The transport lane associated with the event: 0 Application, 1 Completion. */
|
|
142
|
+
readonly transportLane: number;
|
|
143
|
+
/** Event-specific flags, including the connection-ready edge flag. */
|
|
144
|
+
readonly flags: number;
|
|
145
|
+
private constructor();
|
|
146
|
+
}
|
|
147
|
+
/** Observes a socket's connection lifecycle events and current status. */
|
|
148
|
+
export interface MonitorSocket {
|
|
149
|
+
/** Receive the next monitor event, or null when `DontWait` is set and none is available. */
|
|
150
|
+
recv(flags?: number): MonitorEvent | null;
|
|
151
|
+
/** Return a snapshot of the monitored socket's current status. */
|
|
152
|
+
status(): MonitorStatus;
|
|
153
|
+
/** Close the monitor and release its resources. */
|
|
154
|
+
close(): void;
|
|
155
|
+
}
|
|
156
|
+
/** Canonical socket-monitor name used by event-source APIs. */
|
|
157
|
+
export type SocketMonitor = MonitorSocket;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MonitorEvent = exports.MonitorEventFlag = exports.MonitorEventType = exports.MonitorSourceKind = void 0;
|
|
5
|
+
/** Identifies what a monitored source is. The Core raw API defines only the socket source. */
|
|
6
|
+
exports.MonitorSourceKind = Object.freeze({ Socket: 1 });
|
|
7
|
+
/** The kind of a delivered socket monitor connection-lifecycle event. */
|
|
8
|
+
exports.MonitorEventType = Object.freeze({
|
|
9
|
+
Connected: 0x0001,
|
|
10
|
+
ConnectDelayed: 0x0002,
|
|
11
|
+
ConnectRetried: 0x0004,
|
|
12
|
+
Listening: 0x0008,
|
|
13
|
+
BindFailed: 0x0010,
|
|
14
|
+
Accepted: 0x0020,
|
|
15
|
+
AcceptFailed: 0x0040,
|
|
16
|
+
Closed: 0x0080,
|
|
17
|
+
CloseFailed: 0x0100,
|
|
18
|
+
Disconnected: 0x0200,
|
|
19
|
+
MonitorStopped: 0x0400,
|
|
20
|
+
HandshakeFailedNoDetail: 0x0800,
|
|
21
|
+
ConnectionReady: 0x1000,
|
|
22
|
+
HandshakeFailedProtocol: 0x2000,
|
|
23
|
+
HandshakeFailedAuth: 0x4000,
|
|
24
|
+
PeerWeightChanged: 0x8000,
|
|
25
|
+
/** A remote-PAUSE condition was first applied to an affected application pipe. */
|
|
26
|
+
SendFlowPaused: 0x10000,
|
|
27
|
+
/** A remote-PAUSE condition was cleared on an affected application pipe. */
|
|
28
|
+
SendFlowResumed: 0x20000,
|
|
29
|
+
/** A stale or duplicate receive-flow-state frame (old generation or non-advancing epoch) was ignored. */
|
|
30
|
+
FlowStateStale: 0x40000
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Bits carried in `MonitorEvent.flags`. Values match
|
|
34
|
+
* `ZLINK_MONITOR_EVENT_FLAG_*` in `zlink/eventing/api.h`.
|
|
35
|
+
*/
|
|
36
|
+
exports.MonitorEventFlag = Object.freeze({
|
|
37
|
+
/** Set on `ConnectionReady` when the connection changed from not-ready to ready. */
|
|
38
|
+
ConnectionReadyEdge: 0x1,
|
|
39
|
+
/**
|
|
40
|
+
* Set on `SendFlowResumed` when clearing the remote pause left the pipe
|
|
41
|
+
* actually writable. `value` carries the flow epoch.
|
|
42
|
+
*/
|
|
43
|
+
SendFlowWritable: 0x2,
|
|
44
|
+
/**
|
|
45
|
+
* Set on `FlowStateStale` when the frame named a different connection
|
|
46
|
+
* generation. `value` carries the received generation.
|
|
47
|
+
*/
|
|
48
|
+
FlowStateStaleGeneration: 0x4,
|
|
49
|
+
/**
|
|
50
|
+
* Set on `FlowStateStale` when the epoch did not advance inside the
|
|
51
|
+
* current generation. `value` carries the received epoch.
|
|
52
|
+
*/
|
|
53
|
+
FlowStateStaleEpoch: 0x8
|
|
54
|
+
});
|
|
55
|
+
/** A single socket connection-lifecycle event reported by a monitor. */
|
|
56
|
+
class MonitorEvent {
|
|
57
|
+
/** The kind of lifecycle event. */
|
|
58
|
+
event;
|
|
59
|
+
/**
|
|
60
|
+
* An event-specific value, such as an error code, reconnect interval, or
|
|
61
|
+
* (for the flow events) a generation/epoch counter. A full 64-bit unsigned
|
|
62
|
+
* value; use `bigint` arithmetic to read it losslessly.
|
|
63
|
+
*/
|
|
64
|
+
value;
|
|
65
|
+
/** The peer routing id, or null when the event carries none. */
|
|
66
|
+
routingId;
|
|
67
|
+
/** The local endpoint address. */
|
|
68
|
+
localAddr;
|
|
69
|
+
/** The remote endpoint address. */
|
|
70
|
+
remoteAddr;
|
|
71
|
+
/** Process-local identity of the physical transport attempt. */
|
|
72
|
+
connectionId;
|
|
73
|
+
/** The transport lane associated with the event: 0 Application, 1 Completion. */
|
|
74
|
+
transportLane;
|
|
75
|
+
/** Event-specific flags, including the connection-ready edge flag. */
|
|
76
|
+
flags;
|
|
77
|
+
constructor() {
|
|
78
|
+
throw new TypeError('MonitorEvent values are created by monitor recv operations');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.MonitorEvent = MonitorEvent;
|
|
82
|
+
Object.freeze(MonitorEvent);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { BaseSocket } from '../sockets';
|
|
2
|
+
import type { PollEventFlagValue } from '../sockets/socket_constants';
|
|
3
|
+
import type { SocketMonitor } from './monitor';
|
|
4
|
+
import type { Timer } from './timer';
|
|
5
|
+
/** A source that can be identified in a poll result; numbers are raw file descriptors. */
|
|
6
|
+
export type Pollable = BaseSocket | SocketMonitor | Timer | number;
|
|
7
|
+
/** One ready source reported by {@link Poller.wait}. */
|
|
8
|
+
export interface PollEvent {
|
|
9
|
+
/** The registered object, or the raw file descriptor, that became ready. */
|
|
10
|
+
readonly source: Pollable;
|
|
11
|
+
/** Whether the ready source is a socket, file descriptor, or timer. */
|
|
12
|
+
readonly sourceKind: number;
|
|
13
|
+
/** The caller token supplied when the source was registered. */
|
|
14
|
+
readonly slot: number;
|
|
15
|
+
/** The events that fired, as a mask of poll flags. */
|
|
16
|
+
readonly revents: number;
|
|
17
|
+
/** The file descriptor, when the source is a raw fd. */
|
|
18
|
+
readonly fd: number;
|
|
19
|
+
}
|
|
20
|
+
/** A reusable buffer of poll results filled by {@link Poller.wait}. */
|
|
21
|
+
export interface PollEvents {
|
|
22
|
+
/** The maximum number of results the buffer can hold. */
|
|
23
|
+
readonly capacity: number;
|
|
24
|
+
/** The number of ready sources written by the last wait. */
|
|
25
|
+
readonly readyCount: number;
|
|
26
|
+
/** The source kind of the result at `index`. */
|
|
27
|
+
sourceKind(index: number): number;
|
|
28
|
+
/** The registered object, or raw file descriptor, for the result at `index`. */
|
|
29
|
+
source(index: number): Pollable;
|
|
30
|
+
/** The caller token of the result at `index`. */
|
|
31
|
+
slot(index: number): number;
|
|
32
|
+
/** The fired-event mask of the result at `index`. */
|
|
33
|
+
revents(index: number): number;
|
|
34
|
+
/** The file descriptor of the result at `index`. */
|
|
35
|
+
fd(index: number): number;
|
|
36
|
+
/** Whether the result at `index` includes `event`. */
|
|
37
|
+
hasEvent(index: number, event: PollEventFlagValue): boolean;
|
|
38
|
+
/** Release the buffer. */
|
|
39
|
+
close(): void;
|
|
40
|
+
}
|
|
41
|
+
/** Multiplexes sockets, socket monitors, file descriptors, and timers. */
|
|
42
|
+
export interface Poller {
|
|
43
|
+
/** The number of registered sources. */
|
|
44
|
+
readonly size: number;
|
|
45
|
+
/** Register `socket` to be watched for `events`; `slot` is echoed back in the matching result. */
|
|
46
|
+
add(socket: BaseSocket, events: readonly PollEventFlagValue[], slot: number): void;
|
|
47
|
+
/** Register `monitor`; socket monitors support `PollIn` only. */
|
|
48
|
+
add(monitor: SocketMonitor, events: readonly PollEventFlagValue[], slot: number): void;
|
|
49
|
+
/** Register `timer`; its expirations surface as poll events tagged with `slot`. */
|
|
50
|
+
add(timer: Timer, slot: number): void;
|
|
51
|
+
/** Change the watched events for an already-registered socket. */
|
|
52
|
+
modify(socket: BaseSocket, events: readonly PollEventFlagValue[]): void;
|
|
53
|
+
/** Change a monitor registration; socket monitors support `PollIn` only. */
|
|
54
|
+
modify(monitor: SocketMonitor, events: readonly PollEventFlagValue[]): void;
|
|
55
|
+
/** Unregister `socket`; return true when it was registered. */
|
|
56
|
+
remove(socket: BaseSocket): boolean;
|
|
57
|
+
/** Unregister `monitor`; return true when it was registered. */
|
|
58
|
+
remove(monitor: SocketMonitor): boolean;
|
|
59
|
+
/** Unregister `timer`; return true when it was registered. */
|
|
60
|
+
remove(timer: Timer): boolean;
|
|
61
|
+
/** Register raw file descriptor `fd` to be watched for `events`; `slot` is echoed back. */
|
|
62
|
+
addFd(fd: number, events: readonly PollEventFlagValue[], slot: number): void;
|
|
63
|
+
/** Change the watched events for an already-registered file descriptor. */
|
|
64
|
+
modifyFd(fd: number, events: readonly PollEventFlagValue[]): void;
|
|
65
|
+
/** Unregister file descriptor `fd`; return true when it was registered. */
|
|
66
|
+
removeFd(fd: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Wait up to `timeoutMs` for sources to become ready, filling `events`; a
|
|
69
|
+
* negative timeout blocks indefinitely. `PollOut` is the WRITABLE wake for
|
|
70
|
+
* managed sends; `PollCompletion` means the owned completion queue
|
|
71
|
+
* (REQUEST and any WRITABLE records) was drained.
|
|
72
|
+
*/
|
|
73
|
+
wait(events: PollEvents, timeoutMs: number): number;
|
|
74
|
+
/** Close the poller and release its resources. */
|
|
75
|
+
close(): void;
|
|
76
|
+
}
|