coakka-v2-connector-node 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CONSUMING.md +48 -0
  2. package/LICENSE.md +115 -0
  3. package/README.md +147 -0
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.js +5 -0
  6. package/dist/models.d.ts +119 -0
  7. package/dist/models.js +150 -0
  8. package/dist/orchestrator.d.ts +80 -0
  9. package/dist/orchestrator.js +260 -0
  10. package/dist/packaging.d.ts +4 -0
  11. package/dist/packaging.js +4 -0
  12. package/dist/protobuf.d.ts +63 -0
  13. package/dist/protobuf.js +323 -0
  14. package/dist/runtime-client.d.ts +124 -0
  15. package/dist/runtime-client.js +922 -0
  16. package/dist/runtime-ffi.d.ts +105 -0
  17. package/dist/runtime-ffi.js +282 -0
  18. package/native/.gitkeep +1 -0
  19. package/native/linux-aarch64/libcoakka_runtime_v2-1.3.1+bda2ef5.so +0 -0
  20. package/native/linux-aarch64/libcoakka_runtime_v2.so +0 -0
  21. package/native/linux-x86_64/libcoakka_runtime_v2-1.3.1+bda2ef5.so +0 -0
  22. package/native/linux-x86_64/libcoakka_runtime_v2.so +0 -0
  23. package/native/macos-aarch64/libcoakka_runtime_v2-1.3.1+bda2ef5.dylib +0 -0
  24. package/native/macos-aarch64/libcoakka_runtime_v2.dylib +0 -0
  25. package/native/windows-aarch64/libcoakka_runtime_v2-1.3.1+bda2ef5.dll +0 -0
  26. package/native/windows-aarch64/libcoakka_runtime_v2.dll +0 -0
  27. package/native/windows-x86_64/libcoakka_runtime_v2-1.3.1+bda2ef5.dll +0 -0
  28. package/native/windows-x86_64/libcoakka_runtime_v2.dll +0 -0
  29. package/package.json +35 -0
  30. package/vendor/koffi/LICENSE.txt +22 -0
  31. package/vendor/koffi/build/koffi/darwin_arm64/koffi.node +0 -0
  32. package/vendor/koffi/build/koffi/darwin_x64/koffi.node +0 -0
  33. package/vendor/koffi/build/koffi/freebsd_arm64/koffi.node +0 -0
  34. package/vendor/koffi/build/koffi/freebsd_ia32/koffi.node +0 -0
  35. package/vendor/koffi/build/koffi/freebsd_x64/koffi.node +0 -0
  36. package/vendor/koffi/build/koffi/linux_arm64/koffi.node +0 -0
  37. package/vendor/koffi/build/koffi/linux_armhf/koffi.node +0 -0
  38. package/vendor/koffi/build/koffi/linux_ia32/koffi.node +0 -0
  39. package/vendor/koffi/build/koffi/linux_loong64/koffi.node +0 -0
  40. package/vendor/koffi/build/koffi/linux_riscv64d/koffi.node +0 -0
  41. package/vendor/koffi/build/koffi/linux_x64/koffi.node +0 -0
  42. package/vendor/koffi/build/koffi/musl_arm64/koffi.node +0 -0
  43. package/vendor/koffi/build/koffi/musl_x64/koffi.node +0 -0
  44. package/vendor/koffi/build/koffi/openbsd_ia32/koffi.node +0 -0
  45. package/vendor/koffi/build/koffi/openbsd_x64/koffi.node +0 -0
  46. package/vendor/koffi/build/koffi/win32_arm64/koffi.exp +0 -0
  47. package/vendor/koffi/build/koffi/win32_arm64/koffi.lib +0 -0
  48. package/vendor/koffi/build/koffi/win32_arm64/koffi.node +0 -0
  49. package/vendor/koffi/build/koffi/win32_ia32/koffi.exp +0 -0
  50. package/vendor/koffi/build/koffi/win32_ia32/koffi.lib +0 -0
  51. package/vendor/koffi/build/koffi/win32_ia32/koffi.node +0 -0
  52. package/vendor/koffi/build/koffi/win32_x64/koffi.exp +0 -0
  53. package/vendor/koffi/build/koffi/win32_x64/koffi.lib +0 -0
  54. package/vendor/koffi/build/koffi/win32_x64/koffi.node +0 -0
  55. package/vendor/koffi/index.d.ts +288 -0
  56. package/vendor/koffi/index.js +634 -0
  57. package/vendor/koffi/package.json +38 -0
package/CONSUMING.md ADDED
@@ -0,0 +1,48 @@
1
+ # Consuming `coakka-v2-connector-node`
2
+
3
+ The Node.js runtime package is a binary tarball that embeds the native v2
4
+ runtime. Applications normally do not need to pass a native library path.
5
+
6
+ ```ts
7
+ import {
8
+ ConnectorStartSpec,
9
+ EndpointFlag,
10
+ localRoute,
11
+ PayloadFormat,
12
+ PayloadIdentity,
13
+ RuntimeHost,
14
+ } from "coakka-v2-connector-node";
15
+ ```
16
+
17
+ For local development or diagnostics, an explicit native library path can be
18
+ provided:
19
+
20
+ ```ts
21
+ RuntimeHost.start(startSpec, "/abs/path/to/libcoakka_runtime_v2.so");
22
+ ```
23
+
24
+ The environment override is:
25
+
26
+ ```sh
27
+ COAKKA_RUNTIME_LIB=/abs/path/to/libcoakka_runtime_v2.so
28
+ ```
29
+
30
+ Current embedded native package:
31
+
32
+ - native core version: `1.3.1`
33
+ - native package version: `1.3.1+bda2ef5`
34
+ - platforms: `macos-aarch64`, `linux-aarch64`, `linux-x86_64`,
35
+ `windows-aarch64`, `windows-x86_64`
36
+
37
+ One Node.js process may start one active `RuntimeHost`. Close it from the app
38
+ lifecycle hook before starting another host in the same process.
39
+
40
+ First-run helpers:
41
+
42
+ ```ts
43
+ const requestIdentity = PayloadIdentity.text("demo.echo.request.v1");
44
+ const routes = [localRoute("svc.echo")];
45
+ ```
46
+
47
+ Use `PayloadFormat.TEXT` for plain text in user-facing code. `PLAIN_TEXT`
48
+ remains as a compatibility alias for the legacy wire-format name.
package/LICENSE.md ADDED
@@ -0,0 +1,115 @@
1
+ # CoAkka Public Artifact Preview License 1.0
2
+
3
+ Effective: 2026-07-19
4
+
5
+ This repository is the public binary artifact surface for CoAkka. It contains
6
+ headers, native libraries, connector packages, Maven artifacts, checksums, and
7
+ artifact metadata. It is not a source-build repository.
8
+
9
+ Unless a specific release artifact includes different license terms, the
10
+ artifacts in this repository are made available under the following preview
11
+ terms.
12
+
13
+ This is not an OSI-approved open source license. The separate
14
+ `coakka-samples` repository may use a permissive open source license for sample
15
+ code and documentation; that sample license does not change the terms for the
16
+ artifacts distributed from this repository.
17
+
18
+ ## Definitions
19
+
20
+ `Artifacts` means the CoAkka binaries, headers, libraries, connector packages,
21
+ Maven artifacts, container-bundle files, checksums, manifests, and release
22
+ metadata distributed from this repository or from an official release page for
23
+ this repository.
24
+
25
+ `Production` means any environment that serves live end-user traffic, live
26
+ customer data, live operational data, revenue-generating workloads, or
27
+ customer-facing workloads outside development, test, CI, sample execution, or
28
+ proof-of-concept evaluation.
29
+
30
+ `Official sample images` means container images published by the CoAkka
31
+ project or repository owner, including the current
32
+ `docker.io/gabrielgun1983/*` sample image namespace and any future images
33
+ published under an official CoAkka container namespace, that bundle unmodified
34
+ artifacts solely to run official CoAkka samples.
35
+
36
+ ## Allowed Use
37
+
38
+ You may download, copy, and use the artifacts from this repository to:
39
+
40
+ - evaluate CoAkka locally
41
+ - run the official public samples
42
+ - build proof-of-concept integrations
43
+ - run development and test environments for applications that integrate with
44
+ CoAkka
45
+ - run CI jobs, automated tests, and integration verification for
46
+ non-production applications or evaluations
47
+ - run company evaluations, proofs of concept, and integration tests,
48
+ including evaluations inside commercial organizations
49
+ - redistribute unmodified CoAkka artifacts inside local development, test, or
50
+ sample environments, provided this notice and the included checksums or
51
+ manifests remain available
52
+ - pull, cache internally, and run official sample images for local development,
53
+ CI, test, sample execution, proof-of-concept integration, and evaluation
54
+
55
+ ## Reserved Uses
56
+
57
+ The following uses require a separate written license:
58
+
59
+ - selling, hosting, or offering CoAkka artifacts as a managed runtime service
60
+ - running CoAkka artifacts in production systems
61
+ - bundling CoAkka artifacts into a product distributed to customers
62
+ - redistributing CoAkka artifacts as part of a paid product, support package,
63
+ appliance, cloud image, or hosted service
64
+ - offering a product or service that presents modified CoAkka artifacts as
65
+ official CoAkka artifacts
66
+ - removing or obscuring copyright, license, checksum, or provenance notices
67
+ - reverse engineering artifacts except where that restriction is prohibited by
68
+ applicable law
69
+ - using the CoAkka name, package names, artifact names, image names, or other
70
+ project identifiers in a way that implies endorsement of an unofficial fork,
71
+ hosted service, or product
72
+
73
+ ## Official Samples
74
+
75
+ Official sample images may bundle unmodified artifacts solely so users can run
76
+ official CoAkka samples without installing the artifacts manually.
77
+
78
+ This sample-image permission does not grant third parties the right to create,
79
+ publish, sell, host, or distribute derivative images for production, customer
80
+ distribution, hosted services, paid support packages, appliances, or cloud
81
+ marketplace offerings.
82
+
83
+ ## Production Use
84
+
85
+ These preview terms are intended for developer evaluation, sample execution,
86
+ non-production proof-of-concept work, CI, and integration testing. Production
87
+ use, hosted service use, customer distribution, and paid redistribution require
88
+ explicit release terms or a separate written agreement.
89
+
90
+ For production, hosted service, customer distribution, paid redistribution, or
91
+ other commercial rights, contact the project through `SUPPORT.md`.
92
+
93
+ ## No Warranty
94
+
95
+ The artifacts are provided as-is, without warranties or conditions of any kind,
96
+ to the maximum extent permitted by applicable law.
97
+
98
+ ## Limitation Of Liability
99
+
100
+ To the maximum extent permitted by applicable law, the project contributors and
101
+ artifact publishers are not liable for any direct, indirect, incidental,
102
+ special, consequential, exemplary, or other damages arising from use of the
103
+ artifacts.
104
+
105
+ ## No Patent Or Trademark Grant
106
+
107
+ These preview terms do not grant patent rights, trademark rights, or rights to
108
+ use the CoAkka name beyond the limited artifact and sample uses allowed above.
109
+ Trademark use is governed by `TRADEMARKS.md`.
110
+
111
+ ## Legal Notice
112
+
113
+ This file is not legal advice. If your intended use depends on legal
114
+ interpretation of these terms, consult your own counsel or request a separate
115
+ written agreement.
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # coakka-v2-connector-node
2
+
3
+ Node.js connector package for the CoAkka runtime v2.
4
+
5
+ Current package shape:
6
+
7
+ - `RuntimeHost.start(...)` as the preferred single-process lifecycle entrypoint
8
+ - `ConnectorOrchestrator.start(...)` remains as the compatibility name for the
9
+ same runtime host
10
+ - `NodeRuntimeClient` as the lower-level request/reply engine
11
+ - `submitRequestTyped(...)`, `submitRequestJson(...)`, `submitRequestRaw(...)`
12
+ - `terminalEvents({ signal, bufferCapacity })`
13
+ - typed payload identity helpers around `messageType`, `payloadSchemaVersion`,
14
+ and `payloadFormat`, including `PayloadIdentity.text(...)`
15
+ - `localRoute(...)` for same-process targets so first-run samples do not spell
16
+ host/port placeholders or endpoint flag numbers by hand
17
+ - control snapshot apply helpers
18
+ - monitor doorbell wait helpers
19
+ - delivered-request lane enabled by default for request/reply hosts, with an
20
+ advanced override for measured one-way-only hosts
21
+
22
+ Request/reply lane in Node.js now has two host API shapes over the same runtime contract:
23
+
24
+ - `ask...`: submit and wait inline
25
+ - `submitRequest...` + `terminalEvents(...)`: submit now, consume terminal outcome (`response` or `deadletter`) later through an async iterator
26
+
27
+ `terminalEvents(...)` is a connector-owned API shape, not a separate transport mode.
28
+
29
+ ## Before / After
30
+
31
+ Before, local application code had to start from the connector-internal
32
+ orchestration name:
33
+
34
+ ```ts
35
+ import {
36
+ ConnectorOrchestrator,
37
+ PayloadFormat,
38
+ PayloadIdentity,
39
+ } from "@coakka/v2-connector-node";
40
+
41
+ const connector = ConnectorOrchestrator.start({
42
+ systemName: "customer-local",
43
+ nodeId: "customer-local-node",
44
+ routes: [],
45
+ });
46
+ const requestIdentity = new PayloadIdentity(
47
+ "customer.create.request.v1",
48
+ 1,
49
+ PayloadFormat.JSON,
50
+ );
51
+
52
+ try {
53
+ const response = await connector.askJson(
54
+ "customer-api",
55
+ "customer.create",
56
+ { name: "Ada" },
57
+ requestIdentity,
58
+ );
59
+ } finally {
60
+ connector.close();
61
+ }
62
+ ```
63
+
64
+ After, the same single-process runtime is named as the application-owned host:
65
+
66
+ ```ts
67
+ import {
68
+ PayloadFormat,
69
+ PayloadIdentity,
70
+ RuntimeHost,
71
+ } from "@coakka/v2-connector-node";
72
+
73
+ const runtime = RuntimeHost.start({
74
+ systemName: "customer-local",
75
+ nodeId: "customer-local-node",
76
+ routes: [],
77
+ });
78
+ const requestIdentity = new PayloadIdentity(
79
+ "customer.create.request.v1",
80
+ 1,
81
+ PayloadFormat.JSON,
82
+ );
83
+
84
+ try {
85
+ const response = await runtime.askJson(
86
+ "customer-api",
87
+ "customer.create",
88
+ { name: "Ada" },
89
+ requestIdentity,
90
+ );
91
+ } finally {
92
+ runtime.close();
93
+ }
94
+ ```
95
+
96
+ `ConnectorOrchestrator` remains available for existing code. New local-first
97
+ Spring Boot, Quarkus, CRUD, and script-style examples should prefer
98
+ `RuntimeHost` so the first screen reads as one embedded runtime owner, not a
99
+ remote connector setup.
100
+
101
+ `separateDeliveredRequestLane` defaults to `true`. Most request/reply services
102
+ should leave it alone so inbound handler work stays separate from
103
+ reply/deadletter matching. Set it to `false` only for advanced, measured,
104
+ mostly one-way hosts.
105
+
106
+ Hot-path reading note:
107
+
108
+ - false-sharing is not the first-order hot-path concern for this Node.js layer
109
+ in the same way it is for the native C++ connector
110
+ - the current Node connector cost center is more likely to sit in:
111
+ - native binding boundary and runtime read/write calls
112
+ - wire-codec encode/decode and JS object mapping
113
+ - async iterator buffering around `terminalEvents(...)`
114
+ - event-loop and worker handoff topology
115
+ - only revisit cacheline-style hardening here if this layer later moves toward
116
+ packed native-side state, off-heap rings, or a flatter shared-memory layout
117
+
118
+ Install dependencies for local development:
119
+
120
+ ```sh
121
+ cd node
122
+ npm install
123
+ ```
124
+
125
+ Build:
126
+
127
+ ```sh
128
+ npm run build
129
+ ```
130
+
131
+ The build stages release-shaped native libraries from:
132
+
133
+ ```text
134
+ v2/staging/native/1.3.1+bda2ef5/
135
+ ```
136
+
137
+ Test:
138
+
139
+ ```sh
140
+ npm test
141
+ ```
142
+
143
+ Packaged consumer smoke:
144
+
145
+ ```sh
146
+ npm run smoke:packaged
147
+ ```
@@ -0,0 +1,6 @@
1
+ export { COAKKA_V2_NATIVE_CORE_VERSION, COAKKA_V2_NATIVE_GIT_COMMIT, COAKKA_V2_NATIVE_PACKAGE_VERSION, COAKKA_V2_NODE_VERSION, } from "./packaging.js";
2
+ export { BusinessStatus, DeliveryHint, EndpointFlag, MessageKind, OverloadMode, PayloadFormat, PayloadIdentity, RequestTerminalEventKind, RouteStrategy, localRoute, requireValidConnectorConfig, requireValidRuntimeOverloadPolicy, requireValidRoute, toConnectorConfig, type ConnectorConfig, type ConnectorStartSpec, type EndpointSpec, type MaybePromise, type ObservedDeadletter, type RuntimeOverloadPolicy, type RequestTerminalEvent, type RequestTerminalEventDeadletter, type RequestTerminalEventResponse, type RouteSpec, type SubmittedRequest, } from "./models.js";
3
+ export { ConnectorOrchestrator, RuntimeHost, RuntimeLibraryResolver, } from "./orchestrator.js";
4
+ export { DeadletterError, NodeRuntimeClient, type HandlerFn, type MonitorSnapshot, type RuntimeClientStats, type DeadlettersOptions, type TerminalEventsOptions, } from "./runtime-client.js";
5
+ export type { ControlEnvelope, RouteSnapshotPayload, TransportDeadletter, TransportEnvelope, } from "./protobuf.js";
6
+ export { COAKKA_ABI_VERSION, COAKKA_OK, HOST_HANDLES_ENABLE_MONITOR, HOST_HANDLES_SEPARATE_DELIVERED_REQUEST_LANE, type HostHandlesSnapshot, type RuntimeConfigSnapshot, type RuntimeHealthSnapshot, type RuntimeInfoSnapshot, type RuntimeStatsSnapshot, } from "./runtime-ffi.js";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { COAKKA_V2_NATIVE_CORE_VERSION, COAKKA_V2_NATIVE_GIT_COMMIT, COAKKA_V2_NATIVE_PACKAGE_VERSION, COAKKA_V2_NODE_VERSION, } from "./packaging.js";
2
+ export { BusinessStatus, DeliveryHint, EndpointFlag, MessageKind, OverloadMode, PayloadFormat, PayloadIdentity, RequestTerminalEventKind, RouteStrategy, localRoute, requireValidConnectorConfig, requireValidRuntimeOverloadPolicy, requireValidRoute, toConnectorConfig, } from "./models.js";
3
+ export { ConnectorOrchestrator, RuntimeHost, RuntimeLibraryResolver, } from "./orchestrator.js";
4
+ export { DeadletterError, NodeRuntimeClient, } from "./runtime-client.js";
5
+ export { COAKKA_ABI_VERSION, COAKKA_OK, HOST_HANDLES_ENABLE_MONITOR, HOST_HANDLES_SEPARATE_DELIVERED_REQUEST_LANE, } from "./runtime-ffi.js";
@@ -0,0 +1,119 @@
1
+ export declare enum MessageKind {
2
+ UNSPECIFIED = 0,
3
+ REQUEST = 1,
4
+ RESPONSE = 2,
5
+ EVENT = 3
6
+ }
7
+ export declare enum BusinessStatus {
8
+ UNSPECIFIED = 0,
9
+ OK = 1,
10
+ ERROR = 2
11
+ }
12
+ export declare enum DeliveryHint {
13
+ UNSPECIFIED = 0,
14
+ ROUTER_DEFAULT = 1,
15
+ PREFER_LOCAL = 2,
16
+ REQUIRE_LOCAL = 3,
17
+ REQUIRE_REMOTE = 4
18
+ }
19
+ export declare enum PayloadFormat {
20
+ UNSPECIFIED = 0,
21
+ JSON = 1,
22
+ PROTOBUF = 2,
23
+ THRIFT = 3,
24
+ MSGPACK = 4,
25
+ TEXT = 5,
26
+ PLAIN_TEXT = 5,
27
+ BINARY = 6
28
+ }
29
+ export declare enum RouteStrategy {
30
+ UNSPECIFIED = 0,
31
+ SINGLE_OWNER = 1,
32
+ WEIGHTED_ROUND_ROBIN = 2,
33
+ RENDEZVOUS_HASH = 3
34
+ }
35
+ export declare enum EndpointFlag {
36
+ NONE = 0,
37
+ LOCAL = 1,
38
+ UNAVAILABLE = 2
39
+ }
40
+ export declare enum OverloadMode {
41
+ REJECT = 0,
42
+ DROP_EXPIRED_FIRST = 1,
43
+ DROP_ONE_WAY_FIRST = 2
44
+ }
45
+ export interface RuntimeOverloadPolicy {
46
+ ingressMode?: OverloadMode;
47
+ localDeliveryMode?: OverloadMode;
48
+ remoteOutboundMode?: OverloadMode;
49
+ remoteOutboundReplyReserveSlots?: number;
50
+ }
51
+ export type MaybePromise<T> = T | Promise<T>;
52
+ export declare class PayloadIdentity {
53
+ readonly messageType: string;
54
+ readonly payloadSchemaVersion: number;
55
+ readonly payloadFormat: PayloadFormat;
56
+ constructor(messageType: string, payloadSchemaVersion?: number, payloadFormat?: PayloadFormat);
57
+ isTyped(): boolean;
58
+ requireTyped(what?: string): PayloadIdentity;
59
+ static text(messageType: string, payloadSchemaVersion?: number): PayloadIdentity;
60
+ }
61
+ export interface EndpointSpec {
62
+ host: string;
63
+ port: number;
64
+ weight?: number;
65
+ flags?: number;
66
+ }
67
+ export interface RouteSpec {
68
+ target: string;
69
+ endpoints: readonly EndpointSpec[];
70
+ strategy?: RouteStrategy;
71
+ routeKeyHint?: string;
72
+ flags?: number;
73
+ }
74
+ export interface ConnectorConfig {
75
+ systemName: string;
76
+ nodeId: string;
77
+ routes: readonly RouteSpec[];
78
+ strictNoDrop?: boolean;
79
+ queueCapacity?: number;
80
+ enableMonitor?: boolean;
81
+ separateDeliveredRequestLane?: boolean;
82
+ generation?: number;
83
+ overloadPolicy?: RuntimeOverloadPolicy;
84
+ }
85
+ export interface ConnectorStartSpec extends ConnectorConfig {
86
+ }
87
+ export interface SubmittedRequest {
88
+ messageId: string;
89
+ correlationId: string;
90
+ }
91
+ export declare const RequestTerminalEventKind: {
92
+ readonly RESPONSE: "response";
93
+ readonly DEADLETTER: "deadletter";
94
+ };
95
+ export type RequestTerminalEventKind = (typeof RequestTerminalEventKind)[keyof typeof RequestTerminalEventKind];
96
+ export interface RequestTerminalEventResponse {
97
+ kind: typeof RequestTerminalEventKind.RESPONSE;
98
+ requestMessageId: string;
99
+ correlationId: string;
100
+ envelope: import("./protobuf.js").TransportEnvelope;
101
+ }
102
+ export interface RequestTerminalEventDeadletter {
103
+ kind: typeof RequestTerminalEventKind.DEADLETTER;
104
+ requestMessageId: string;
105
+ correlationId: string;
106
+ deadletter: import("./protobuf.js").TransportDeadletter;
107
+ }
108
+ export type RequestTerminalEvent = RequestTerminalEventResponse | RequestTerminalEventDeadletter;
109
+ export interface ObservedDeadletter {
110
+ deadletter: import("./protobuf.js").TransportDeadletter;
111
+ requestMessageId: string | null;
112
+ correlationId: string | null;
113
+ matchedPendingRequest: boolean;
114
+ }
115
+ export declare function requireValidRoute(route: RouteSpec): RouteSpec;
116
+ export declare function localRoute(target: string, port?: number): RouteSpec;
117
+ export declare function requireValidRuntimeOverloadPolicy(policy: RuntimeOverloadPolicy, what?: string): RuntimeOverloadPolicy;
118
+ export declare function requireValidConnectorConfig(config: ConnectorConfig): ConnectorConfig;
119
+ export declare function toConnectorConfig(startSpec: ConnectorStartSpec): ConnectorConfig;
package/dist/models.js ADDED
@@ -0,0 +1,150 @@
1
+ export var MessageKind;
2
+ (function (MessageKind) {
3
+ MessageKind[MessageKind["UNSPECIFIED"] = 0] = "UNSPECIFIED";
4
+ MessageKind[MessageKind["REQUEST"] = 1] = "REQUEST";
5
+ MessageKind[MessageKind["RESPONSE"] = 2] = "RESPONSE";
6
+ MessageKind[MessageKind["EVENT"] = 3] = "EVENT";
7
+ })(MessageKind || (MessageKind = {}));
8
+ export var BusinessStatus;
9
+ (function (BusinessStatus) {
10
+ BusinessStatus[BusinessStatus["UNSPECIFIED"] = 0] = "UNSPECIFIED";
11
+ BusinessStatus[BusinessStatus["OK"] = 1] = "OK";
12
+ BusinessStatus[BusinessStatus["ERROR"] = 2] = "ERROR";
13
+ })(BusinessStatus || (BusinessStatus = {}));
14
+ export var DeliveryHint;
15
+ (function (DeliveryHint) {
16
+ DeliveryHint[DeliveryHint["UNSPECIFIED"] = 0] = "UNSPECIFIED";
17
+ DeliveryHint[DeliveryHint["ROUTER_DEFAULT"] = 1] = "ROUTER_DEFAULT";
18
+ DeliveryHint[DeliveryHint["PREFER_LOCAL"] = 2] = "PREFER_LOCAL";
19
+ DeliveryHint[DeliveryHint["REQUIRE_LOCAL"] = 3] = "REQUIRE_LOCAL";
20
+ DeliveryHint[DeliveryHint["REQUIRE_REMOTE"] = 4] = "REQUIRE_REMOTE";
21
+ })(DeliveryHint || (DeliveryHint = {}));
22
+ export var PayloadFormat;
23
+ (function (PayloadFormat) {
24
+ PayloadFormat[PayloadFormat["UNSPECIFIED"] = 0] = "UNSPECIFIED";
25
+ PayloadFormat[PayloadFormat["JSON"] = 1] = "JSON";
26
+ PayloadFormat[PayloadFormat["PROTOBUF"] = 2] = "PROTOBUF";
27
+ PayloadFormat[PayloadFormat["THRIFT"] = 3] = "THRIFT";
28
+ PayloadFormat[PayloadFormat["MSGPACK"] = 4] = "MSGPACK";
29
+ PayloadFormat[PayloadFormat["TEXT"] = 5] = "TEXT";
30
+ PayloadFormat[PayloadFormat["PLAIN_TEXT"] = 5] = "PLAIN_TEXT";
31
+ PayloadFormat[PayloadFormat["BINARY"] = 6] = "BINARY";
32
+ })(PayloadFormat || (PayloadFormat = {}));
33
+ export var RouteStrategy;
34
+ (function (RouteStrategy) {
35
+ RouteStrategy[RouteStrategy["UNSPECIFIED"] = 0] = "UNSPECIFIED";
36
+ RouteStrategy[RouteStrategy["SINGLE_OWNER"] = 1] = "SINGLE_OWNER";
37
+ RouteStrategy[RouteStrategy["WEIGHTED_ROUND_ROBIN"] = 2] = "WEIGHTED_ROUND_ROBIN";
38
+ RouteStrategy[RouteStrategy["RENDEZVOUS_HASH"] = 3] = "RENDEZVOUS_HASH";
39
+ })(RouteStrategy || (RouteStrategy = {}));
40
+ export var EndpointFlag;
41
+ (function (EndpointFlag) {
42
+ EndpointFlag[EndpointFlag["NONE"] = 0] = "NONE";
43
+ EndpointFlag[EndpointFlag["LOCAL"] = 1] = "LOCAL";
44
+ EndpointFlag[EndpointFlag["UNAVAILABLE"] = 2] = "UNAVAILABLE";
45
+ })(EndpointFlag || (EndpointFlag = {}));
46
+ export var OverloadMode;
47
+ (function (OverloadMode) {
48
+ OverloadMode[OverloadMode["REJECT"] = 0] = "REJECT";
49
+ OverloadMode[OverloadMode["DROP_EXPIRED_FIRST"] = 1] = "DROP_EXPIRED_FIRST";
50
+ OverloadMode[OverloadMode["DROP_ONE_WAY_FIRST"] = 2] = "DROP_ONE_WAY_FIRST";
51
+ })(OverloadMode || (OverloadMode = {}));
52
+ export class PayloadIdentity {
53
+ messageType;
54
+ payloadSchemaVersion;
55
+ payloadFormat;
56
+ constructor(messageType, payloadSchemaVersion = 1, payloadFormat = PayloadFormat.UNSPECIFIED) {
57
+ this.messageType = messageType;
58
+ this.payloadSchemaVersion = payloadSchemaVersion;
59
+ this.payloadFormat = payloadFormat;
60
+ }
61
+ isTyped() {
62
+ return (this.messageType.trim() !== "" &&
63
+ this.payloadSchemaVersion >= 1 &&
64
+ this.payloadFormat !== PayloadFormat.UNSPECIFIED);
65
+ }
66
+ requireTyped(what = "payload identity") {
67
+ if (this.messageType.trim() === "") {
68
+ throw new Error(`${what} requires messageType`);
69
+ }
70
+ if (this.payloadSchemaVersion < 1) {
71
+ throw new Error(`${what} requires payloadSchemaVersion >= 1`);
72
+ }
73
+ if (this.payloadFormat === PayloadFormat.UNSPECIFIED) {
74
+ throw new Error(`${what} requires declared payloadFormat`);
75
+ }
76
+ return this;
77
+ }
78
+ static text(messageType, payloadSchemaVersion = 1) {
79
+ return new PayloadIdentity(messageType, payloadSchemaVersion, PayloadFormat.TEXT);
80
+ }
81
+ }
82
+ export const RequestTerminalEventKind = {
83
+ RESPONSE: "response",
84
+ DEADLETTER: "deadletter",
85
+ };
86
+ export function requireValidRoute(route) {
87
+ if (route.target.trim() === "") {
88
+ throw new Error("route requires target");
89
+ }
90
+ if (route.endpoints.length === 0) {
91
+ throw new Error(`route target=${route.target} requires at least one endpoint`);
92
+ }
93
+ return route;
94
+ }
95
+ export function localRoute(target, port = 9001) {
96
+ return {
97
+ target,
98
+ endpoints: [{ host: "127.0.0.1", port, flags: EndpointFlag.LOCAL }],
99
+ };
100
+ }
101
+ export function requireValidRuntimeOverloadPolicy(policy, what = "overloadPolicy") {
102
+ if ((policy.ingressMode ?? OverloadMode.REJECT) !== OverloadMode.REJECT) {
103
+ throw new Error(`${what}.ingressMode currently supports only REJECT`);
104
+ }
105
+ if ((policy.localDeliveryMode ?? OverloadMode.REJECT) !== OverloadMode.REJECT) {
106
+ throw new Error(`${what}.localDeliveryMode currently supports only REJECT`);
107
+ }
108
+ if ((policy.remoteOutboundReplyReserveSlots ?? 0) < 0) {
109
+ throw new Error(`${what}.remoteOutboundReplyReserveSlots must be >= 0`);
110
+ }
111
+ return policy;
112
+ }
113
+ export function requireValidConnectorConfig(config) {
114
+ if (config.systemName.trim() === "") {
115
+ throw new Error("connector config requires systemName");
116
+ }
117
+ if (config.nodeId.trim() === "") {
118
+ throw new Error("connector config requires nodeId");
119
+ }
120
+ if ((config.queueCapacity ?? 128) < 1) {
121
+ throw new Error("connector config requires queueCapacity >= 1");
122
+ }
123
+ if ((config.generation ?? 1) < 1) {
124
+ throw new Error("connector config requires generation >= 1");
125
+ }
126
+ if (config.overloadPolicy != null) {
127
+ requireValidRuntimeOverloadPolicy(config.overloadPolicy, "connector config overloadPolicy");
128
+ }
129
+ if (config.routes.length === 0) {
130
+ throw new Error("connector config requires at least one route");
131
+ }
132
+ for (const route of config.routes) {
133
+ requireValidRoute(route);
134
+ }
135
+ return config;
136
+ }
137
+ export function toConnectorConfig(startSpec) {
138
+ requireValidConnectorConfig(startSpec);
139
+ return {
140
+ systemName: startSpec.systemName,
141
+ nodeId: startSpec.nodeId,
142
+ routes: startSpec.routes,
143
+ strictNoDrop: startSpec.strictNoDrop ?? true,
144
+ queueCapacity: startSpec.queueCapacity ?? 128,
145
+ enableMonitor: startSpec.enableMonitor ?? true,
146
+ separateDeliveredRequestLane: startSpec.separateDeliveredRequestLane ?? true,
147
+ generation: startSpec.generation ?? 1,
148
+ overloadPolicy: startSpec.overloadPolicy,
149
+ };
150
+ }
@@ -0,0 +1,80 @@
1
+ import type { PathLike } from "node:fs";
2
+ import { type ConnectorConfig, type ConnectorStartSpec, DeliveryHint, type ObservedDeadletter, type PayloadIdentity, type RequestTerminalEvent, type SubmittedRequest } from "./models.js";
3
+ import type { TransportEnvelope } from "./protobuf.js";
4
+ import type { HandlerFn, DeadlettersOptions, MonitorSnapshot, RuntimeClientStats, TerminalEventsOptions } from "./runtime-client.js";
5
+ import { NodeRuntimeClient } from "./runtime-client.js";
6
+ export declare class RuntimeLibraryResolver {
7
+ static readonly envVar = "COAKKA_RUNTIME_LIB";
8
+ static resolve(explicitPath?: string | PathLike, candidateNames?: readonly string[]): string;
9
+ static platformId(osName?: NodeJS.Platform, archName?: NodeJS.Architecture): string;
10
+ static normalizeOs(osName: string): string;
11
+ static normalizeArch(archName: string): string;
12
+ static runtimeResourceFileNamesForCurrentPlatform(osName?: NodeJS.Platform): string[];
13
+ private static resolveEmbedded;
14
+ private static searchCandidates;
15
+ private static requireExisting;
16
+ }
17
+ declare class ControlApi {
18
+ private readonly orchestrator;
19
+ constructor(orchestrator: ConnectorOrchestrator);
20
+ applySnapshot(generation: number, routes: ConnectorConfig["routes"], sourceConnector?: string, seq?: number, overloadPolicy?: ConnectorConfig["overloadPolicy"]): void;
21
+ }
22
+ declare class MonitorApi {
23
+ private readonly orchestrator;
24
+ constructor(orchestrator: ConnectorOrchestrator);
25
+ isEnabled(): boolean;
26
+ snapshot(signalCount?: number): MonitorSnapshot;
27
+ awaitNext(timeoutMs?: number): Promise<MonitorSnapshot | null>;
28
+ awaitAppliedGenerationAtLeast(generation: number, timeoutMs?: number): Promise<MonitorSnapshot | null>;
29
+ }
30
+ export declare class ConnectorOrchestrator {
31
+ readonly runtimeLibPath: string;
32
+ readonly startSpec: ConnectorStartSpec;
33
+ readonly client: NodeRuntimeClient;
34
+ private static active;
35
+ static start(startSpec: ConnectorStartSpec, runtimeLibPath?: string | PathLike): ConnectorOrchestrator;
36
+ readonly control: ControlApi;
37
+ readonly monitor: MonitorApi;
38
+ private closed;
39
+ private constructor();
40
+ askTyped(source: string, target: string, payload: Uint8Array, payloadIdentity: PayloadIdentity, timeoutMs?: number, operation?: string, deliveryHint?: DeliveryHint, headers?: Record<string, string>): Promise<TransportEnvelope>;
41
+ askJson(source: string, target: string, payload: Record<string, unknown>, payloadIdentity: PayloadIdentity, timeoutMs?: number, operation?: string, deliveryHint?: DeliveryHint, headers?: Record<string, string>): Promise<Record<string, unknown>>;
42
+ askRaw(request: TransportEnvelope, timeoutMs?: number): Promise<TransportEnvelope>;
43
+ submitRequestTyped(source: string, target: string, payload: Uint8Array, payloadIdentity: PayloadIdentity, timeoutMs?: number, operation?: string, deliveryHint?: DeliveryHint, headers?: Record<string, string>): SubmittedRequest;
44
+ submitRequestJson(source: string, target: string, payload: Record<string, unknown>, payloadIdentity: PayloadIdentity, timeoutMs?: number, operation?: string, deliveryHint?: DeliveryHint, headers?: Record<string, string>): SubmittedRequest;
45
+ submitRequestRaw(request: TransportEnvelope): SubmittedRequest;
46
+ terminalEvents(options?: TerminalEventsOptions): AsyncIterableIterator<RequestTerminalEvent>;
47
+ deadletters(options?: DeadlettersOptions): AsyncIterableIterator<ObservedDeadletter>;
48
+ sendOneWayTyped(source: string, target: string, payload: Uint8Array, payloadIdentity: PayloadIdentity, deliveryHint?: DeliveryHint, headers?: Record<string, string>): void;
49
+ sendOneWayJson(source: string, target: string, payload: Record<string, unknown>, payloadIdentity: PayloadIdentity, deliveryHint?: DeliveryHint, headers?: Record<string, string>): void;
50
+ submitEnvelope(envelope: TransportEnvelope): void;
51
+ submitTypedEnvelope(envelope: TransportEnvelope): void;
52
+ submitRawEnvelope(envelope: TransportEnvelope): void;
53
+ registerHandler(target: string, handler: HandlerFn, typedReplies?: boolean): void;
54
+ registerRawHandler(target: string, handler: HandlerFn): void;
55
+ clientStats(): RuntimeClientStats;
56
+ runtimeInfo(): import("./runtime-ffi.js").RuntimeInfoSnapshot;
57
+ runtimeConfig(): import("./runtime-ffi.js").RuntimeConfigSnapshot;
58
+ health(): import("./runtime-ffi.js").RuntimeHealthSnapshot;
59
+ stats(): import("./runtime-ffi.js").RuntimeStatsSnapshot;
60
+ runtimeSnapshot(): {
61
+ runtimeInfo: import("./runtime-ffi.js").RuntimeInfoSnapshot;
62
+ runtimeConfig: import("./runtime-ffi.js").RuntimeConfigSnapshot;
63
+ connector: RuntimeClientStats & {
64
+ separateDeliveredRequestLane: boolean;
65
+ systemName: string;
66
+ nodeId: string;
67
+ };
68
+ health: import("./runtime-ffi.js").RuntimeHealthSnapshot;
69
+ stats: import("./runtime-ffi.js").RuntimeStatsSnapshot;
70
+ };
71
+ applySnapshot(generation: number, routes: ConnectorConfig["routes"], sourceConnector?: string, seq?: number, overloadPolicy?: import("./models.js").RuntimeOverloadPolicy | undefined): void;
72
+ monitorIsEnabled(): boolean;
73
+ monitorSnapshot(signalCount?: number): MonitorSnapshot;
74
+ awaitNextMonitor(timeoutMs?: number): Promise<MonitorSnapshot | null>;
75
+ awaitAppliedGenerationAtLeast(generation: number, timeoutMs?: number): Promise<MonitorSnapshot | null>;
76
+ close(): void;
77
+ }
78
+ export declare const RuntimeHost: typeof ConnectorOrchestrator;
79
+ export type RuntimeHost = ConnectorOrchestrator;
80
+ export {};