@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,84 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This repository contains third-party source code and/or redistributable binaries.
|
|
4
|
+
This file summarizes known components and where their license texts are located.
|
|
5
|
+
|
|
6
|
+
## Bundled source dependencies
|
|
7
|
+
|
|
8
|
+
- Boost (header-only subset)
|
|
9
|
+
- Location: `core/external/boost/`
|
|
10
|
+
- License text: `core/external/boost/LICENSE_1_0.txt`
|
|
11
|
+
- License type: Boost Software License 1.0
|
|
12
|
+
|
|
13
|
+
- moodycamel::ConcurrentQueue
|
|
14
|
+
- Location: `core/external/moodycamel/`
|
|
15
|
+
- License text: `core/external/moodycamel/LICENSE`
|
|
16
|
+
- License type: Simplified BSD (2-Clause)
|
|
17
|
+
|
|
18
|
+
- wepoll
|
|
19
|
+
- Location: `core/external/wepoll/`
|
|
20
|
+
- License text: `core/external/wepoll/license.txt`
|
|
21
|
+
- License type: BSD-2-Clause style
|
|
22
|
+
|
|
23
|
+
- Unity test framework
|
|
24
|
+
- Location: `core/external/unity/`
|
|
25
|
+
- License text: `core/external/unity/license.txt`
|
|
26
|
+
- License type: MIT
|
|
27
|
+
|
|
28
|
+
- SHA1 implementation (WIDE Project)
|
|
29
|
+
- Location: `core/external/sha1/`
|
|
30
|
+
- License text: `core/external/sha1/license.txt`
|
|
31
|
+
- License type: BSD-3-Clause style
|
|
32
|
+
|
|
33
|
+
## Bundled runtime binaries in bindings
|
|
34
|
+
|
|
35
|
+
The following folders include prebuilt runtime binaries for convenience:
|
|
36
|
+
|
|
37
|
+
- `bindings/node/prebuilds/`
|
|
38
|
+
- `bindings/dotnet/runtimes/*/native/`
|
|
39
|
+
- `bindings/java/src/main/resources/native/`
|
|
40
|
+
- `bindings/cpp/native/`
|
|
41
|
+
- `bindings/python/src/zlink/native/`
|
|
42
|
+
|
|
43
|
+
These artifacts may include components such as:
|
|
44
|
+
|
|
45
|
+
- zlink/libzlink binaries
|
|
46
|
+
- Microsoft Visual C++ runtime DLLs (Windows targets)
|
|
47
|
+
- OpenSSL runtime libraries, depending on package/target
|
|
48
|
+
|
|
49
|
+
When redistributing these artifacts, ensure the corresponding third-party
|
|
50
|
+
license obligations are met for your target platform and package format.
|
|
51
|
+
|
|
52
|
+
## Origin of `core/`
|
|
53
|
+
|
|
54
|
+
`core/` began as a fork of [libzmq](https://github.com/zeromq/libzmq) v4.3.5,
|
|
55
|
+
narrowed to a smaller set of socket patterns and re-platformed onto Boost.Asio
|
|
56
|
+
and OpenSSL (see `core/doc/guide/design-rationale.ko.md` for the technical
|
|
57
|
+
rationale). Separately, as public upstream history: libzmq v4.3.5 is the
|
|
58
|
+
release at which the libzmq project itself completed relicensing from
|
|
59
|
+
LGPLv3 + static-linking exception to MPL-2.0. `core/` therefore carries the
|
|
60
|
+
MPL-2.0 license forward from that upstream lineage. The upstream copyright
|
|
61
|
+
holders and contributors are recorded verbatim (as of v4.3.5) in
|
|
62
|
+
[`core/AUTHORS`](./core/AUTHORS), vendored from libzmq for that reason.
|
|
63
|
+
|
|
64
|
+
## Project License
|
|
65
|
+
|
|
66
|
+
This repository uses three licenses, split by layer:
|
|
67
|
+
|
|
68
|
+
- `core/` and `bindings/` (per-language native bindings) are licensed under
|
|
69
|
+
MPL-2.0. See `LICENSE`.
|
|
70
|
+
- `framework/` (the higher-level framework built on top of the bindings) is
|
|
71
|
+
licensed under FSL-1.1-ALv2 (Functional Source License 1.1, Apache-2.0
|
|
72
|
+
Future License). See `framework/LICENSE`.
|
|
73
|
+
- Each language's `http-client` package under `framework/` (a thin wrapper
|
|
74
|
+
over that platform's commonly used HTTP client library — .NET's
|
|
75
|
+
`System.Net.Http`, Java/Kotlin's `java.net.http`, Node's `undici`, C++'s
|
|
76
|
+
Boost.Beast) is licensed under Apache License 2.0 instead of FSL, because
|
|
77
|
+
it wraps a permissively-licensed library rather than any zlink-original
|
|
78
|
+
transport. The .NET and Node packages declare this directly in their own
|
|
79
|
+
manifest; the Java and Kotlin packages receive it from the shared Gradle
|
|
80
|
+
publish configuration; the C++ package ships the license text alongside
|
|
81
|
+
its sources.
|
|
82
|
+
|
|
83
|
+
Unless otherwise noted, source code outside `framework/` is licensed under
|
|
84
|
+
MPL-2.0.
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "zlink",
|
|
5
|
+
"sources": [
|
|
6
|
+
"native/src/addon.cc",
|
|
7
|
+
"native/src/addon_core.cc",
|
|
8
|
+
"native/src/addon_core_options.cc",
|
|
9
|
+
"native/src/addon_exports.cc"
|
|
10
|
+
],
|
|
11
|
+
"include_dirs": [ "<!(node scripts/resolve_core.js include)" ],
|
|
12
|
+
"variables": {
|
|
13
|
+
"zlink_lib%": "<!(node scripts/resolve_core.js library)"
|
|
14
|
+
},
|
|
15
|
+
"conditions": [
|
|
16
|
+
[ "\"<(zlink_lib)\" != \"\"", { "libraries": [ "<(zlink_lib)" ] } ],
|
|
17
|
+
[ "OS==\"linux\"", { "ldflags": [ "-Wl,-rpath,\\$$ORIGIN" ] } ],
|
|
18
|
+
[ "OS==\"mac\"", {
|
|
19
|
+
"ldflags": [ "-Wl,-rpath,@loader_path" ],
|
|
20
|
+
"xcode_settings": {
|
|
21
|
+
"LD_RUNPATH_SEARCH_PATHS": [ "@loader_path" ]
|
|
22
|
+
}
|
|
23
|
+
} ]
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './zlink/contracts';
|
|
2
|
+
import type { AtomicCounter, Context, DealerSocket, PairSocket, Poller, PollEvents, PubSocket, RouterSocket, Stopwatch, StreamSocket, SubSocket, Thread, Timer, XPubSocket, XSubSocket } from './zlink/contracts';
|
|
3
|
+
import type { BaseSocket, Message } from './zlink/contracts';
|
|
4
|
+
export declare function createContext(): Context;
|
|
5
|
+
export declare function createPairSocket(ctx: Context): PairSocket;
|
|
6
|
+
export declare function createPubSocket(ctx: Context): PubSocket;
|
|
7
|
+
export declare function createSubSocket(ctx: Context): SubSocket;
|
|
8
|
+
export declare function createXPubSocket(ctx: Context): XPubSocket;
|
|
9
|
+
export declare function createXSubSocket(ctx: Context): XSubSocket;
|
|
10
|
+
export declare function createDealerSocket(ctx: Context): DealerSocket;
|
|
11
|
+
export declare function createRouterSocket(ctx: Context): RouterSocket;
|
|
12
|
+
export declare function createStreamSocket(ctx: Context): StreamSocket;
|
|
13
|
+
export declare function createPoller(): Poller;
|
|
14
|
+
export declare function createPollEvents(capacity: number): PollEvents;
|
|
15
|
+
export declare function createTimer(): Timer;
|
|
16
|
+
export declare function createThread(handler: () => void): Thread;
|
|
17
|
+
export declare function createStopwatch(): Stopwatch;
|
|
18
|
+
export declare function createAtomicCounter(initialValue?: number): AtomicCounter;
|
|
19
|
+
export declare function version(): [number, number, number];
|
|
20
|
+
export declare function strerror(code: number): string;
|
|
21
|
+
export declare function has(capability: string): boolean;
|
|
22
|
+
export declare function proxy(frontend: BaseSocket, backend: BaseSocket, capture?: BaseSocket): void;
|
|
23
|
+
export declare function sleep(seconds: number): void;
|
|
24
|
+
export declare function multipartClose(parts: Message[]): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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.createContext = createContext;
|
|
19
|
+
exports.createPairSocket = createPairSocket;
|
|
20
|
+
exports.createPubSocket = createPubSocket;
|
|
21
|
+
exports.createSubSocket = createSubSocket;
|
|
22
|
+
exports.createXPubSocket = createXPubSocket;
|
|
23
|
+
exports.createXSubSocket = createXSubSocket;
|
|
24
|
+
exports.createDealerSocket = createDealerSocket;
|
|
25
|
+
exports.createRouterSocket = createRouterSocket;
|
|
26
|
+
exports.createStreamSocket = createStreamSocket;
|
|
27
|
+
exports.createPoller = createPoller;
|
|
28
|
+
exports.createPollEvents = createPollEvents;
|
|
29
|
+
exports.createTimer = createTimer;
|
|
30
|
+
exports.createThread = createThread;
|
|
31
|
+
exports.createStopwatch = createStopwatch;
|
|
32
|
+
exports.createAtomicCounter = createAtomicCounter;
|
|
33
|
+
exports.version = version;
|
|
34
|
+
exports.strerror = strerror;
|
|
35
|
+
exports.has = has;
|
|
36
|
+
exports.proxy = proxy;
|
|
37
|
+
exports.sleep = sleep;
|
|
38
|
+
exports.multipartClose = multipartClose;
|
|
39
|
+
__exportStar(require("./zlink/contracts"), exports);
|
|
40
|
+
const message_1 = require("./zlink/contracts/messaging/message");
|
|
41
|
+
const native_1 = require("./zlink/runtime/native/native");
|
|
42
|
+
const runtime_info_1 = require("./zlink/runtime/core/runtime_info");
|
|
43
|
+
const context_1 = require("./zlink/runtime/core/context");
|
|
44
|
+
const eventing_1 = require("./zlink/runtime/eventing");
|
|
45
|
+
const sockets_1 = require("./zlink/runtime/sockets");
|
|
46
|
+
const public_bridge_1 = require("./zlink/runtime/public_bridge");
|
|
47
|
+
(0, message_1.configureMessageNativeOperations)({
|
|
48
|
+
allocate: (size) => (0, native_1.requireNative)().messageAllocate(size),
|
|
49
|
+
close: (nativeMessage) => (0, native_1.requireNative)().messageFrameClose(nativeMessage),
|
|
50
|
+
data: (nativeMessage) => (0, native_1.requireNative)().messageFrameData(nativeMessage),
|
|
51
|
+
copyData: (nativeMessage) => (0, native_1.requireNative)().messageFrameCopyData(nativeMessage),
|
|
52
|
+
fromBuffer: (data) => (0, native_1.requireNative)().messageFromBuffer(data),
|
|
53
|
+
size: (nativeMessage) => (0, native_1.requireNative)().messageFrameSize(nativeMessage),
|
|
54
|
+
});
|
|
55
|
+
function createContext() {
|
|
56
|
+
return (0, public_bridge_1.asPublicContract)(new context_1.RuntimeContext());
|
|
57
|
+
}
|
|
58
|
+
function createPairSocket(ctx) {
|
|
59
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimePairSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
60
|
+
}
|
|
61
|
+
function createPubSocket(ctx) {
|
|
62
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimePubSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
63
|
+
}
|
|
64
|
+
function createSubSocket(ctx) {
|
|
65
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimeSubSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
66
|
+
}
|
|
67
|
+
function createXPubSocket(ctx) {
|
|
68
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimeXPubSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
69
|
+
}
|
|
70
|
+
function createXSubSocket(ctx) {
|
|
71
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimeXSubSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
72
|
+
}
|
|
73
|
+
function createDealerSocket(ctx) {
|
|
74
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimeDealerSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
75
|
+
}
|
|
76
|
+
function createRouterSocket(ctx) {
|
|
77
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimeRouterSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
78
|
+
}
|
|
79
|
+
function createStreamSocket(ctx) {
|
|
80
|
+
return (0, public_bridge_1.asPublicContract)(new sockets_1.RuntimeStreamSocket((0, public_bridge_1.asRuntimeContext)(ctx)));
|
|
81
|
+
}
|
|
82
|
+
function createPoller() {
|
|
83
|
+
return (0, public_bridge_1.asPublicContract)(new eventing_1.RuntimePoller());
|
|
84
|
+
}
|
|
85
|
+
function createPollEvents(capacity) {
|
|
86
|
+
return (0, public_bridge_1.asPublicContract)(new eventing_1.RuntimePollEvents(capacity));
|
|
87
|
+
}
|
|
88
|
+
function createTimer() {
|
|
89
|
+
return (0, public_bridge_1.asPublicContract)(new eventing_1.RuntimeTimer());
|
|
90
|
+
}
|
|
91
|
+
function createThread(handler) {
|
|
92
|
+
return (0, public_bridge_1.asPublicContract)(new eventing_1.RuntimeThread(handler));
|
|
93
|
+
}
|
|
94
|
+
function createStopwatch() {
|
|
95
|
+
return (0, public_bridge_1.asPublicContract)(new eventing_1.RuntimeStopwatch());
|
|
96
|
+
}
|
|
97
|
+
function createAtomicCounter(initialValue = 0) {
|
|
98
|
+
return (0, public_bridge_1.asPublicContract)(new eventing_1.RuntimeAtomicCounter(initialValue));
|
|
99
|
+
}
|
|
100
|
+
function version() {
|
|
101
|
+
return (0, runtime_info_1.version)();
|
|
102
|
+
}
|
|
103
|
+
function strerror(code) {
|
|
104
|
+
return (0, runtime_info_1.strerror)(code);
|
|
105
|
+
}
|
|
106
|
+
function has(capability) {
|
|
107
|
+
return (0, runtime_info_1.has)(capability);
|
|
108
|
+
}
|
|
109
|
+
function proxy(frontend, backend, capture) {
|
|
110
|
+
(0, runtime_info_1.proxy)((0, public_bridge_1.asRuntimeSocket)(frontend), (0, public_bridge_1.asRuntimeSocket)(backend), capture ? (0, public_bridge_1.asRuntimeSocket)(capture) : undefined);
|
|
111
|
+
}
|
|
112
|
+
function sleep(seconds) {
|
|
113
|
+
(0, runtime_info_1.sleep)(seconds);
|
|
114
|
+
}
|
|
115
|
+
function multipartClose(parts) {
|
|
116
|
+
(0, runtime_info_1.multipartClose)(parts);
|
|
117
|
+
}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Generated from src/index.ts by scripts/generate_esm_wrapper.js.
|
|
2
|
+
import cjs from './index.js';
|
|
3
|
+
export default cjs;
|
|
4
|
+
export const { AutoHwmProfile, BindError, BindResult, CloseError, CloseResult, CompletionKind, ConfigError, ConfigResult, ConnectError, ConnectResult, createAtomicCounter, createContext, createDealerSocket, createPairSocket, createPoller, createPollEvents, createPubSocket, createRouterSocket, createStopwatch, createStreamSocket, createSubSocket, createThread, createTimer, createXPubSocket, createXSubSocket, HandlerError, HandlerResult, has, Message, MonitorEvent, MonitorEventFlag, MonitorEventType, MonitorSourceKind, multipartClose, PollEventFlag, proxy, Received, ReceiveFlowState, RecvError, RecvFlags, RecvResult, ReplyToken, RequestError, RequestResult, RidDuplicatePolicy, RoutingId, SendFlags, sleep, SOCKET_MONITOR_EVENT_ALL, SocketType, StreamPacket, StreamRecvMode, strerror, SubmitError, SubmitResult, SubmitRetryMode, SubscriptionEvent, TopicMessage, version, ZlinkError } = cjs;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** An automatic high-water-mark sizing profile trading memory, latency, and throughput. */
|
|
2
|
+
export declare const AutoHwmProfile: Readonly<{
|
|
3
|
+
readonly Compact: 0;
|
|
4
|
+
readonly LowLatency: 1;
|
|
5
|
+
readonly Balanced: 2;
|
|
6
|
+
readonly Throughput: 3;
|
|
7
|
+
}>;
|
|
8
|
+
export type AutoHwmProfileValue = typeof AutoHwmProfile[keyof typeof AutoHwmProfile];
|
|
9
|
+
/** Immutable Core Auto HWM ABI-v1 context budget snapshot. */
|
|
10
|
+
export interface CoreHwmBudgetSnapshot {
|
|
11
|
+
readonly abiVersion: number;
|
|
12
|
+
readonly structSize: number;
|
|
13
|
+
readonly budgetGeneration: bigint;
|
|
14
|
+
readonly measurementEpoch: bigint;
|
|
15
|
+
readonly configuredMemoryLimitBytes: bigint;
|
|
16
|
+
readonly runtimeMemoryLimitBytes: bigint;
|
|
17
|
+
readonly resolvedMemoryLimitBytes: bigint;
|
|
18
|
+
readonly configuredCoreBudgetBytes: bigint;
|
|
19
|
+
readonly effectiveCoreBudgetBytes: bigint;
|
|
20
|
+
readonly totalPlannedHwmBytes: bigint;
|
|
21
|
+
readonly totalAppliedHwmBytes: bigint;
|
|
22
|
+
readonly manualReservedHwmBytes: bigint;
|
|
23
|
+
readonly coreQueueAccountedBytes: bigint;
|
|
24
|
+
readonly applicationAccountedBytes: bigint;
|
|
25
|
+
readonly currentAccountedBytes: bigint;
|
|
26
|
+
readonly provisionalAccountedBytes: bigint;
|
|
27
|
+
readonly peakAccountedBytes: bigint;
|
|
28
|
+
readonly completionCurrentAccountedBytes: bigint;
|
|
29
|
+
readonly completionPeakAccountedBytes: bigint;
|
|
30
|
+
readonly completionPendingMessageCount: bigint;
|
|
31
|
+
readonly totalMessagingAccountedBytes: bigint;
|
|
32
|
+
readonly monitorQueueAppliedHwmBytes: bigint;
|
|
33
|
+
readonly monitorQueueAccountedBytes: bigint;
|
|
34
|
+
readonly totalInstanceAppliedHwmBytes: bigint;
|
|
35
|
+
readonly totalInstanceAccountedBytes: bigint;
|
|
36
|
+
readonly oversizeAdmissionCount: bigint;
|
|
37
|
+
readonly largestOversizeMessageBytes: bigint;
|
|
38
|
+
readonly activeDirectionalQueueCount: bigint;
|
|
39
|
+
readonly activeCompletionDirectionalQueueCount: bigint;
|
|
40
|
+
readonly activeSendQueueCount: bigint;
|
|
41
|
+
readonly activeReceiveQueueCount: bigint;
|
|
42
|
+
readonly outstandingApplicationLeaseCount: bigint;
|
|
43
|
+
readonly retiredQueueCount: bigint;
|
|
44
|
+
readonly deferredOriginCreditBytes: bigint;
|
|
45
|
+
readonly unlimitedManualQueueCount: bigint;
|
|
46
|
+
readonly blockedRatioPpm: number;
|
|
47
|
+
readonly flags: number;
|
|
48
|
+
readonly reservedUInt64: readonly bigint[];
|
|
49
|
+
readonly budgetPlanningActive: boolean;
|
|
50
|
+
readonly budgetInsufficient: boolean;
|
|
51
|
+
readonly aggregateHwmValid: boolean;
|
|
52
|
+
readonly aggregateOverflow: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** Context-wide options governing the I/O threads and defaults shared by every socket. */
|
|
55
|
+
export interface ContextOptions {
|
|
56
|
+
/** The number of background I/O threads serving the context. */
|
|
57
|
+
ioThreads: number;
|
|
58
|
+
/** The maximum number of sockets the context may create. */
|
|
59
|
+
maxSockets: number;
|
|
60
|
+
/** The largest value `maxSockets` may take on this build. */
|
|
61
|
+
readonly socketLimit: number;
|
|
62
|
+
/** The default maximum inbound message size, in bytes, for new sockets. */
|
|
63
|
+
maxMsgSize: number;
|
|
64
|
+
/** The size of the context's message worker thread pool. */
|
|
65
|
+
readonly msgTSize: number;
|
|
66
|
+
/** The OS scheduling priority of the context's I/O threads. */
|
|
67
|
+
threadPriority: number;
|
|
68
|
+
/** The OS scheduling policy of the context's I/O threads. */
|
|
69
|
+
threadSchedulingPolicy: number;
|
|
70
|
+
/** Whether the context blocks on termination until queued messages are sent. */
|
|
71
|
+
blocky: boolean;
|
|
72
|
+
/** Whether high-water marks are sized automatically. */
|
|
73
|
+
autoHwmEnabled: boolean;
|
|
74
|
+
/** The minimum delay, in ms, between automatic high-water-mark recalculations. */
|
|
75
|
+
autoHwmRecalcDebounceMs: number;
|
|
76
|
+
/** The profile used to divide the Core memory budget. */
|
|
77
|
+
coreHwmProfile: AutoHwmProfileValue;
|
|
78
|
+
/** Explicit context memory limit in bytes; 0n selects automatic detection. */
|
|
79
|
+
coreHwmMemoryLimitBytes: bigint;
|
|
80
|
+
/** Explicit context-wide Core budget in bytes; 0n derives it from the memory limit. */
|
|
81
|
+
coreHwmBudgetBytes: bigint;
|
|
82
|
+
/** The prefix applied to the names of threads the context creates. */
|
|
83
|
+
threadNamePrefix: string;
|
|
84
|
+
/** Pin the context's I/O threads to also run on CPU core `cpu`. */
|
|
85
|
+
addThreadAffinity(cpu: number): void;
|
|
86
|
+
/** Remove CPU core `cpu` from the context's I/O thread affinity. */
|
|
87
|
+
removeThreadAffinity(cpu: number): void;
|
|
88
|
+
}
|
|
89
|
+
/** A messaging context: the factory and owner of sockets and event sources. */
|
|
90
|
+
export interface Context {
|
|
91
|
+
/** The context-wide options facade. */
|
|
92
|
+
readonly options: ContextOptions;
|
|
93
|
+
/** Terminate the context, interrupting blocking operations on its sockets without closing them. */
|
|
94
|
+
shutdown(): void;
|
|
95
|
+
/** Recompute automatic high-water marks for the context's sockets immediately. */
|
|
96
|
+
recalculateAutoHwm(): void;
|
|
97
|
+
/** Return an immutable value snapshot of Core's context-wide HWM budget state. */
|
|
98
|
+
getCoreHwmBudgetSnapshot(): CoreHwmBudgetSnapshot;
|
|
99
|
+
/** Reset epoch metrics while preserving current HWM budget gauges. */
|
|
100
|
+
resetCoreHwmBudgetMetrics(): void;
|
|
101
|
+
/** Close the context and release its resources, terminating anything still open under it. */
|
|
102
|
+
close(): void;
|
|
103
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AutoHwmProfile = void 0;
|
|
5
|
+
/** An automatic high-water-mark sizing profile trading memory, latency, and throughput. */
|
|
6
|
+
exports.AutoHwmProfile = Object.freeze({
|
|
7
|
+
Compact: 0,
|
|
8
|
+
LowLatency: 1,
|
|
9
|
+
Balanced: 2,
|
|
10
|
+
Throughput: 3
|
|
11
|
+
});
|
|
@@ -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("./buffer_like"), exports);
|
|
19
|
+
__exportStar(require("./context"), exports);
|
|
20
|
+
__exportStar(require("./routing_id"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class RoutingId {
|
|
2
|
+
private readonly _bytes;
|
|
3
|
+
private constructor();
|
|
4
|
+
/**
|
|
5
|
+
* Create a routing id from a string (its UTF-8 bytes), a number (a 4-byte
|
|
6
|
+
* big-endian uint32), or a Buffer/Uint8Array (copied). Throws when the byte
|
|
7
|
+
* length is not 1..255.
|
|
8
|
+
*/
|
|
9
|
+
static from(value: string | Buffer | Uint8Array | number): RoutingId;
|
|
10
|
+
/**
|
|
11
|
+
* Create a routing id by decoding `value` as a hex string (non-empty, even
|
|
12
|
+
* length, up to 510 digits for 255 bytes).
|
|
13
|
+
*/
|
|
14
|
+
static fromHex(value: string): RoutingId;
|
|
15
|
+
/** Return a copy of the routing id bytes. */
|
|
16
|
+
toBytes(): Buffer;
|
|
17
|
+
/** The length of the routing id in bytes. */
|
|
18
|
+
get size(): number;
|
|
19
|
+
/** Return true when `other` has identical bytes. */
|
|
20
|
+
equals(other: RoutingId): boolean;
|
|
21
|
+
/** Return the routing id as a lowercase hex string. */
|
|
22
|
+
toHex(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Return a human-readable form: printable UTF-8 text when possible, otherwise
|
|
25
|
+
* a uint, a UUID, or a `hex:` fallback.
|
|
26
|
+
*/
|
|
27
|
+
toString(): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.RoutingId = void 0;
|
|
5
|
+
const errors_1 = require("../errors/errors");
|
|
6
|
+
const ROUTING_ID_MAX_LENGTH = 255;
|
|
7
|
+
function normalizeRoutingIdBytes(bytes, name) {
|
|
8
|
+
if (!Buffer.isBuffer(bytes) && !(bytes instanceof Uint8Array)) {
|
|
9
|
+
throw new TypeError(`${name} must be a Buffer or Uint8Array`);
|
|
10
|
+
}
|
|
11
|
+
const normalized = Buffer.from(bytes);
|
|
12
|
+
if (normalized.length === 0 || normalized.length > ROUTING_ID_MAX_LENGTH) {
|
|
13
|
+
const error = new errors_1.ConfigError(errors_1.ConfigResult.InvalidArgument, 0);
|
|
14
|
+
error.message = `${name} must be 1..${ROUTING_ID_MAX_LENGTH} bytes`;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
function normalizeRoutingIdHex(value) {
|
|
20
|
+
if (typeof value !== 'string') {
|
|
21
|
+
throw new TypeError('value must be a string');
|
|
22
|
+
}
|
|
23
|
+
if (value.length === 0 || value.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(value)) {
|
|
24
|
+
const error = new errors_1.ConfigError(errors_1.ConfigResult.InvalidArgument, 0);
|
|
25
|
+
error.message = 'value must be a non-empty even-length hex string';
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
if (value.length > ROUTING_ID_MAX_LENGTH * 2) {
|
|
29
|
+
const error = new errors_1.ConfigError(errors_1.ConfigResult.InvalidArgument, 0);
|
|
30
|
+
error.message = `value must decode to at most ${ROUTING_ID_MAX_LENGTH} bytes`;
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
return normalizeRoutingIdBytes(Buffer.from(value, 'hex'), 'value');
|
|
34
|
+
}
|
|
35
|
+
function normalizeRoutingIdValue(value) {
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
return normalizeRoutingIdBytes(Buffer.from(value, 'utf8'), 'value');
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === 'number') {
|
|
40
|
+
if (!Number.isInteger(value) || value < 0 || value > 0xFFFF_FFFF) {
|
|
41
|
+
throw new RangeError('routing id uint32 value must be in range 0..4294967295');
|
|
42
|
+
}
|
|
43
|
+
const buffer = Buffer.allocUnsafe(4);
|
|
44
|
+
buffer.writeUInt32BE(value >>> 0, 0);
|
|
45
|
+
return buffer;
|
|
46
|
+
}
|
|
47
|
+
return normalizeRoutingIdBytes(value, 'value');
|
|
48
|
+
}
|
|
49
|
+
function tryPrintableUtf8(bytes) {
|
|
50
|
+
const text = bytes.toString('utf8');
|
|
51
|
+
if (!Buffer.from(text, 'utf8').equals(bytes)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return /[\u0000-\u001f\u007f-\u009f]/u.test(text) ? null : text;
|
|
55
|
+
}
|
|
56
|
+
function uuidString(bytes) {
|
|
57
|
+
const hex = bytes.toString('hex');
|
|
58
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
59
|
+
}
|
|
60
|
+
/** An opaque identifier for a messaging peer or route, 1 to 255 bytes long. */
|
|
61
|
+
const ROUTING_ID_CONSTRUCTOR_TOKEN = Symbol('RoutingId.constructor');
|
|
62
|
+
class RoutingId {
|
|
63
|
+
_bytes;
|
|
64
|
+
constructor(bytes, token) {
|
|
65
|
+
if (token !== ROUTING_ID_CONSTRUCTOR_TOKEN) {
|
|
66
|
+
throw new TypeError('RoutingId values are created by RoutingId.from or RoutingId.fromHex');
|
|
67
|
+
}
|
|
68
|
+
this._bytes = bytes;
|
|
69
|
+
Object.freeze(this);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a routing id from a string (its UTF-8 bytes), a number (a 4-byte
|
|
73
|
+
* big-endian uint32), or a Buffer/Uint8Array (copied). Throws when the byte
|
|
74
|
+
* length is not 1..255.
|
|
75
|
+
*/
|
|
76
|
+
static from(value) {
|
|
77
|
+
return new RoutingId(normalizeRoutingIdValue(value), ROUTING_ID_CONSTRUCTOR_TOKEN);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a routing id by decoding `value` as a hex string (non-empty, even
|
|
81
|
+
* length, up to 510 digits for 255 bytes).
|
|
82
|
+
*/
|
|
83
|
+
static fromHex(value) {
|
|
84
|
+
return new RoutingId(normalizeRoutingIdHex(value), ROUTING_ID_CONSTRUCTOR_TOKEN);
|
|
85
|
+
}
|
|
86
|
+
/** Return a copy of the routing id bytes. */
|
|
87
|
+
toBytes() {
|
|
88
|
+
return Buffer.from(this._bytes);
|
|
89
|
+
}
|
|
90
|
+
/** The length of the routing id in bytes. */
|
|
91
|
+
get size() {
|
|
92
|
+
return this._bytes.length;
|
|
93
|
+
}
|
|
94
|
+
/** Return true when `other` has identical bytes. */
|
|
95
|
+
equals(other) {
|
|
96
|
+
return other instanceof RoutingId && this._bytes.equals(other._bytes);
|
|
97
|
+
}
|
|
98
|
+
/** Return the routing id as a lowercase hex string. */
|
|
99
|
+
toHex() {
|
|
100
|
+
return this._bytes.toString('hex');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Return a human-readable form: printable UTF-8 text when possible, otherwise
|
|
104
|
+
* a uint, a UUID, or a `hex:` fallback.
|
|
105
|
+
*/
|
|
106
|
+
toString() {
|
|
107
|
+
const utf8 = tryPrintableUtf8(this._bytes);
|
|
108
|
+
if (utf8 !== null) {
|
|
109
|
+
return utf8;
|
|
110
|
+
}
|
|
111
|
+
if (this._bytes.length === 4) {
|
|
112
|
+
return this._bytes.readUInt32BE(0).toString(10);
|
|
113
|
+
}
|
|
114
|
+
if (this._bytes.length === 16) {
|
|
115
|
+
return uuidString(this._bytes);
|
|
116
|
+
}
|
|
117
|
+
return `hex:${this.toHex()}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.RoutingId = RoutingId;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BindResult, CloseResult, ConfigResult, ConnectResult, HandlerResult, RecvResult, RequestResult, SubmitResult } from './results';
|
|
2
|
+
export { BindResult, CloseResult, ConfigResult, ConnectResult, HandlerResult, RecvResult, RequestResult, SubmitResult, } from './results';
|
|
3
|
+
/** Base class for all errors thrown by the zlink bindings; carries a result `code` and the underlying native errno. */
|
|
4
|
+
export declare class ZlinkError extends Error {
|
|
5
|
+
readonly code: number;
|
|
6
|
+
readonly nativeErrno: number;
|
|
7
|
+
constructor(code: number, nativeErrno?: number);
|
|
8
|
+
}
|
|
9
|
+
declare class ResultError<TResult extends number> extends ZlinkError {
|
|
10
|
+
readonly result: TResult;
|
|
11
|
+
protected constructor(name: string, result: TResult, nativeErrno?: number);
|
|
12
|
+
}
|
|
13
|
+
/** Thrown when submitting a send or publish fails. */
|
|
14
|
+
export declare class SubmitError extends ResultError<SubmitResult> {
|
|
15
|
+
constructor(result: SubmitResult, nativeErrno?: number);
|
|
16
|
+
}
|
|
17
|
+
/** Thrown when a request fails or its reply reports an error. */
|
|
18
|
+
export declare class RequestError extends ResultError<RequestResult> {
|
|
19
|
+
constructor(result: RequestResult, nativeErrno?: number);
|
|
20
|
+
}
|
|
21
|
+
/** Thrown when receiving a message fails. */
|
|
22
|
+
export declare class RecvError extends ResultError<RecvResult> {
|
|
23
|
+
constructor(result: RecvResult, nativeErrno?: number);
|
|
24
|
+
}
|
|
25
|
+
/** Thrown when registering or running a callback handler fails. */
|
|
26
|
+
export declare class HandlerError extends ResultError<HandlerResult> {
|
|
27
|
+
constructor(result: HandlerResult, nativeErrno?: number);
|
|
28
|
+
}
|
|
29
|
+
/** Thrown when closing a socket or resource fails. */
|
|
30
|
+
export declare class CloseError extends ResultError<CloseResult> {
|
|
31
|
+
constructor(result: CloseResult, nativeErrno?: number);
|
|
32
|
+
}
|
|
33
|
+
/** Thrown when binding a socket to an endpoint fails. */
|
|
34
|
+
export declare class BindError extends ResultError<BindResult> {
|
|
35
|
+
constructor(result: BindResult, nativeErrno?: number);
|
|
36
|
+
}
|
|
37
|
+
/** Thrown when connecting a socket to an endpoint fails. */
|
|
38
|
+
export declare class ConnectError extends ResultError<ConnectResult> {
|
|
39
|
+
constructor(result: ConnectResult, nativeErrno?: number);
|
|
40
|
+
}
|
|
41
|
+
/** Thrown when reading or applying a configuration option fails. */
|
|
42
|
+
export declare class ConfigError extends ResultError<ConfigResult> {
|
|
43
|
+
constructor(result: ConfigResult, nativeErrno?: number);
|
|
44
|
+
}
|