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
@@ -0,0 +1,105 @@
1
+ export declare const COAKKA_OK = 0;
2
+ export declare const COAKKA_ABI_VERSION = 1;
3
+ export declare const HOST_HANDLES_ENABLE_MONITOR: number;
4
+ export declare const HOST_HANDLES_SEPARATE_DELIVERED_REQUEST_LANE: number;
5
+ export interface RuntimeInfoSnapshot {
6
+ abiVersion: number;
7
+ featureFlags: number;
8
+ runtimeVersion: string;
9
+ gitCommit: string;
10
+ southboundBackend: string;
11
+ allocatorBackend: string;
12
+ docsHint: string;
13
+ }
14
+ export interface RuntimeConfigSnapshot {
15
+ systemName: string;
16
+ nodeId: string;
17
+ runtimeState: number;
18
+ snapshotPresent: boolean;
19
+ appliedGeneration: number;
20
+ routeCount: number;
21
+ southboundBindHost: string;
22
+ southboundBindPort: number;
23
+ effectiveIngressOverloadMode: number;
24
+ effectiveLocalDeliveryOverloadMode: number;
25
+ effectiveRemoteOutboundOverloadMode: number;
26
+ effectiveRemoteOutboundReplyReserveSlots: number;
27
+ }
28
+ export interface RuntimeHealthSnapshot {
29
+ runtimeState: number;
30
+ flags: number;
31
+ appliedGeneration: number;
32
+ }
33
+ export interface RuntimeStatsSnapshot {
34
+ appliedGeneration: number;
35
+ routeCount: number;
36
+ runtimeState: number;
37
+ queueRejectedCount: number;
38
+ routeMissCount: number;
39
+ deadletterCount: number;
40
+ deliveryFailedCount: number;
41
+ controlRejectedCount: number;
42
+ monitorEventEmittedCount: number;
43
+ monitorEventDroppedCount: number;
44
+ monitorEventEmittedLifetimeCount: number;
45
+ monitorEventDroppedLifetimeCount: number;
46
+ localWorkQueueCapacity: number;
47
+ localWorkQueueDepth: number;
48
+ localWorkQueueHighWatermark: number;
49
+ deliveredRequestOutboundDirectWriteCount: number;
50
+ responseOutboundDirectWriteCount: number;
51
+ deadletterOutboundDirectWriteCount: number;
52
+ remoteOutboundQueueCapacity: number;
53
+ remoteOutboundQueueDepth: number;
54
+ remoteOutboundQueueHighWatermark: number;
55
+ remoteOutboundQueueRejectedCount: number;
56
+ remoteOutboundExpiredDropCount: number;
57
+ remoteOutboundReplyReserveSlots: number;
58
+ remoteOutboundReplyReservationRejectCount: number;
59
+ remoteOutboundOneWayDropCount: number;
60
+ }
61
+ export interface HostHandlesSnapshot {
62
+ flags: number;
63
+ requestWriteFd: number;
64
+ responseReadFd: number;
65
+ deadletterReadFd: number;
66
+ controlWriteFd: number;
67
+ monitorReadFd: number;
68
+ deliveredRequestReadFd: number;
69
+ }
70
+ export interface NativeRuntimeConfig {
71
+ systemName: string;
72
+ nodeId: string;
73
+ strictNoDrop: boolean;
74
+ queueCapacity: number;
75
+ }
76
+ export declare class NativeRuntimeBindings {
77
+ readonly runtimeLibPath: string;
78
+ private readonly lib;
79
+ private readonly getAbiVersionFn;
80
+ private readonly getInfoFn;
81
+ private readonly createRuntimeFn;
82
+ private readonly destroyRuntimeFn;
83
+ private readonly getHostHandlesFn;
84
+ private readonly startRuntimeFn;
85
+ private readonly stopRuntimeFn;
86
+ private readonly getHealthFn;
87
+ private readonly getStatsFn;
88
+ private readonly getConfigFn;
89
+ private readonly submitEnvelopeFn;
90
+ private readonly applyControlEnvelopeFn;
91
+ constructor(runtimeLibPath: string);
92
+ getAbiVersion(): number;
93
+ readRuntimeInfo(): RuntimeInfoSnapshot;
94
+ createRuntime(config: NativeRuntimeConfig): unknown;
95
+ destroyRuntime(runtime: unknown): void;
96
+ getHostHandles(runtime: unknown, flags: number): HostHandlesSnapshot;
97
+ startRuntime(runtime: unknown): void;
98
+ stopRuntime(runtime: unknown): void;
99
+ getHealth(runtime: unknown): RuntimeHealthSnapshot;
100
+ getStats(runtime: unknown): RuntimeStatsSnapshot;
101
+ getConfig(runtime: unknown): RuntimeConfigSnapshot;
102
+ submitEnvelope(runtime: unknown, bytes: Uint8Array): void;
103
+ applyControlEnvelope(runtime: unknown, bytes: Uint8Array): void;
104
+ requireOk(rc: number, what: string): void;
105
+ }
@@ -0,0 +1,282 @@
1
+ import koffi from "../vendor/koffi/index.js";
2
+ export const COAKKA_OK = 0;
3
+ export const COAKKA_ABI_VERSION = 1;
4
+ export const HOST_HANDLES_ENABLE_MONITOR = 1 << 0;
5
+ export const HOST_HANDLES_SEPARATE_DELIVERED_REQUEST_LANE = 1 << 1;
6
+ const RuntimeConfigStruct = koffi.struct("coakka_v2_runtime_config_t", {
7
+ system_name: "str",
8
+ node_id: "str",
9
+ strict_no_drop: "int",
10
+ queue_capacity: "int",
11
+ });
12
+ const RuntimeInfoStruct = koffi.struct("coakka_v2_runtime_info_t", {
13
+ struct_size: koffi.types.size_t,
14
+ abi_version: "uint32_t",
15
+ feature_flags: "uint32_t",
16
+ runtime_version: "str",
17
+ git_commit: "str",
18
+ southbound_backend: "str",
19
+ allocator_backend: "str",
20
+ docs_hint: "str",
21
+ });
22
+ const RuntimeConfigViewStruct = koffi.struct("coakka_v2_runtime_config_view_t", {
23
+ struct_size: koffi.types.size_t,
24
+ system_name: "str",
25
+ node_id: "str",
26
+ strict_no_drop: "int",
27
+ queue_capacity: "int",
28
+ request_max_frame_size: koffi.types.size_t,
29
+ local_dispatch_batch_limit: koffi.types.size_t,
30
+ runtime_state: "int",
31
+ snapshot_present: "uint32_t",
32
+ applied_generation: "uint64_t",
33
+ route_count: koffi.types.size_t,
34
+ southbound_bind_host: "str",
35
+ southbound_bind_port: "uint16_t",
36
+ configured_ingress_overload_mode: "uint32_t",
37
+ configured_local_delivery_overload_mode: "uint32_t",
38
+ configured_remote_outbound_overload_mode: "uint32_t",
39
+ configured_remote_outbound_reply_reserve_slots: koffi.types.size_t,
40
+ effective_ingress_overload_mode: "uint32_t",
41
+ effective_local_delivery_overload_mode: "uint32_t",
42
+ effective_remote_outbound_overload_mode: "uint32_t",
43
+ effective_remote_outbound_reply_reserve_slots: koffi.types.size_t,
44
+ });
45
+ const HostHandlesStruct = koffi.struct("coakka_v2_host_handles_t", {
46
+ struct_size: koffi.types.size_t,
47
+ flags: "uint32_t",
48
+ request_write_fd: "int",
49
+ response_read_fd: "int",
50
+ deadletter_read_fd: "int",
51
+ control_write_fd: "int",
52
+ monitor_read_fd: "int",
53
+ delivered_request_read_fd: "int",
54
+ });
55
+ const RuntimeHealthStruct = koffi.struct("coakka_v2_runtime_health_t", {
56
+ struct_size: koffi.types.size_t,
57
+ runtime_state: "int",
58
+ flags: "uint32_t",
59
+ applied_generation: "uint64_t",
60
+ });
61
+ const RuntimeStatsStruct = koffi.struct("coakka_v2_runtime_stats_t", {
62
+ struct_size: koffi.types.size_t,
63
+ applied_generation: "uint64_t",
64
+ route_count: koffi.types.size_t,
65
+ runtime_state: "int",
66
+ ingress_queue_capacity: koffi.types.size_t,
67
+ ingress_queue_depth: koffi.types.size_t,
68
+ ingress_queue_high_watermark: koffi.types.size_t,
69
+ queue_rejected_count: "uint64_t",
70
+ route_miss_count: "uint64_t",
71
+ deadletter_count: "uint64_t",
72
+ delivery_failed_count: "uint64_t",
73
+ remote_transport_failed_count: "uint64_t",
74
+ southbound_submit_attempt_count: "uint64_t",
75
+ southbound_probe_connect_success_count: "uint64_t",
76
+ southbound_probe_connect_failure_count: "uint64_t",
77
+ request_max_frame_size: koffi.types.size_t,
78
+ local_dispatch_batch_limit: koffi.types.size_t,
79
+ delivered_request_outbound_queue_capacity: koffi.types.size_t,
80
+ delivered_request_outbound_queue_depth: koffi.types.size_t,
81
+ delivered_request_outbound_queue_high_watermark: koffi.types.size_t,
82
+ delivered_request_outbound_enqueue_block_count: "uint64_t",
83
+ response_outbound_queue_capacity: koffi.types.size_t,
84
+ response_outbound_queue_depth: koffi.types.size_t,
85
+ response_outbound_queue_high_watermark: koffi.types.size_t,
86
+ response_outbound_enqueue_block_count: "uint64_t",
87
+ deadletter_outbound_queue_capacity: koffi.types.size_t,
88
+ deadletter_outbound_queue_depth: koffi.types.size_t,
89
+ deadletter_outbound_queue_high_watermark: koffi.types.size_t,
90
+ deadletter_outbound_enqueue_block_count: "uint64_t",
91
+ remote_reply_timeout_count: "uint64_t",
92
+ late_remote_reply_drop_count: "uint64_t",
93
+ remote_outbound_queue_capacity: koffi.types.size_t,
94
+ remote_outbound_queue_depth: koffi.types.size_t,
95
+ remote_outbound_queue_high_watermark: koffi.types.size_t,
96
+ remote_outbound_queue_rejected_count: "uint64_t",
97
+ remote_outbound_expired_drop_count: "uint64_t",
98
+ endpoint_unavailable_count: "uint64_t",
99
+ remote_response_forwarded_count: "uint64_t",
100
+ remote_deadletter_forwarded_count: "uint64_t",
101
+ drained_route_count: koffi.types.size_t,
102
+ control_rejected_count: "uint64_t",
103
+ control_invalid_count: "uint64_t",
104
+ control_stale_generation_count: "uint64_t",
105
+ control_bad_state_count: "uint64_t",
106
+ control_io_count: "uint64_t",
107
+ remote_outbound_reply_reserve_slots: koffi.types.size_t,
108
+ remote_outbound_reply_reservation_reject_count: "uint64_t",
109
+ ingress_overload_mode: "uint32_t",
110
+ local_delivery_overload_mode: "uint32_t",
111
+ remote_outbound_overload_mode: "uint32_t",
112
+ monitor_event_emitted_count: "uint64_t",
113
+ monitor_event_dropped_count: "uint64_t",
114
+ monitor_event_emitted_lifetime_count: "uint64_t",
115
+ monitor_event_dropped_lifetime_count: "uint64_t",
116
+ local_work_queue_capacity: koffi.types.size_t,
117
+ local_work_queue_depth: koffi.types.size_t,
118
+ local_work_queue_high_watermark: koffi.types.size_t,
119
+ delivered_request_outbound_direct_write_count: "uint64_t",
120
+ response_outbound_direct_write_count: "uint64_t",
121
+ deadletter_outbound_direct_write_count: "uint64_t",
122
+ remote_outbound_one_way_drop_count: "uint64_t",
123
+ });
124
+ koffi.opaque("coakka_v2_runtime_t");
125
+ function decodeText(value) {
126
+ return value ?? "";
127
+ }
128
+ export class NativeRuntimeBindings {
129
+ runtimeLibPath;
130
+ lib;
131
+ getAbiVersionFn;
132
+ getInfoFn;
133
+ createRuntimeFn;
134
+ destroyRuntimeFn;
135
+ getHostHandlesFn;
136
+ startRuntimeFn;
137
+ stopRuntimeFn;
138
+ getHealthFn;
139
+ getStatsFn;
140
+ getConfigFn;
141
+ submitEnvelopeFn;
142
+ applyControlEnvelopeFn;
143
+ constructor(runtimeLibPath) {
144
+ this.runtimeLibPath = runtimeLibPath;
145
+ this.lib = koffi.load(runtimeLibPath);
146
+ this.getAbiVersionFn = this.lib.func("uint32_t coakka_v2_runtime_get_abi_version(void)");
147
+ this.getInfoFn = this.lib.func("int coakka_v2_runtime_get_info(_Out_ coakka_v2_runtime_info_t *out_info)");
148
+ this.createRuntimeFn = this.lib.func("coakka_v2_runtime_t *coakka_v2_runtime_create(const coakka_v2_runtime_config_t *cfg)");
149
+ this.destroyRuntimeFn = this.lib.func("void coakka_v2_runtime_destroy(coakka_v2_runtime_t *rt)");
150
+ this.getHostHandlesFn = this.lib.func("int coakka_v2_runtime_get_host_handles(coakka_v2_runtime_t *rt, _Inout_ coakka_v2_host_handles_t *out_handles)");
151
+ this.startRuntimeFn = this.lib.func("int coakka_v2_runtime_start(coakka_v2_runtime_t *rt)");
152
+ this.stopRuntimeFn = this.lib.func("int coakka_v2_runtime_stop(coakka_v2_runtime_t *rt)");
153
+ this.getHealthFn = this.lib.func("int coakka_v2_runtime_get_health(coakka_v2_runtime_t *rt, _Out_ coakka_v2_runtime_health_t *out_health)");
154
+ this.getStatsFn = this.lib.func("int coakka_v2_runtime_get_stats(coakka_v2_runtime_t *rt, _Out_ coakka_v2_runtime_stats_t *out_stats)");
155
+ this.getConfigFn = this.lib.func("int coakka_v2_runtime_get_config(coakka_v2_runtime_t *rt, _Out_ coakka_v2_runtime_config_view_t *out_config)");
156
+ this.submitEnvelopeFn = this.lib.func("int coakka_v2_runtime_submit_envelope(coakka_v2_runtime_t *rt, const uint8_t *buf, size_t len)");
157
+ this.applyControlEnvelopeFn = this.lib.func("int coakka_v2_runtime_apply_control_envelope(coakka_v2_runtime_t *rt, const uint8_t *buf, size_t len)");
158
+ }
159
+ getAbiVersion() {
160
+ return this.getAbiVersionFn();
161
+ }
162
+ readRuntimeInfo() {
163
+ const info = { struct_size: koffi.sizeof(RuntimeInfoStruct) };
164
+ this.requireOk(this.getInfoFn(info), "runtime_get_info");
165
+ return {
166
+ abiVersion: Number(info.abi_version),
167
+ featureFlags: Number(info.feature_flags),
168
+ runtimeVersion: decodeText(info.runtime_version),
169
+ gitCommit: decodeText(info.git_commit),
170
+ southboundBackend: decodeText(info.southbound_backend),
171
+ allocatorBackend: decodeText(info.allocator_backend),
172
+ docsHint: decodeText(info.docs_hint),
173
+ };
174
+ }
175
+ createRuntime(config) {
176
+ const runtime = this.createRuntimeFn({
177
+ system_name: config.systemName,
178
+ node_id: config.nodeId,
179
+ strict_no_drop: config.strictNoDrop ? 1 : 0,
180
+ queue_capacity: config.queueCapacity,
181
+ });
182
+ if (runtime == null) {
183
+ throw new Error("coakka_v2_runtime_create returned null");
184
+ }
185
+ return runtime;
186
+ }
187
+ destroyRuntime(runtime) {
188
+ this.destroyRuntimeFn(runtime);
189
+ }
190
+ getHostHandles(runtime, flags) {
191
+ const handles = {
192
+ struct_size: koffi.sizeof(HostHandlesStruct),
193
+ flags,
194
+ };
195
+ this.requireOk(this.getHostHandlesFn(runtime, handles), "get_host_handles");
196
+ return {
197
+ flags: Number(handles.flags),
198
+ requestWriteFd: Number(handles.request_write_fd),
199
+ responseReadFd: Number(handles.response_read_fd),
200
+ deadletterReadFd: Number(handles.deadletter_read_fd),
201
+ controlWriteFd: Number(handles.control_write_fd),
202
+ monitorReadFd: Number(handles.monitor_read_fd),
203
+ deliveredRequestReadFd: Number(handles.delivered_request_read_fd),
204
+ };
205
+ }
206
+ startRuntime(runtime) {
207
+ this.requireOk(this.startRuntimeFn(runtime), "runtime_start");
208
+ }
209
+ stopRuntime(runtime) {
210
+ this.requireOk(this.stopRuntimeFn(runtime), "runtime_stop");
211
+ }
212
+ getHealth(runtime) {
213
+ const health = { struct_size: koffi.sizeof(RuntimeHealthStruct) };
214
+ this.requireOk(this.getHealthFn(runtime, health), "runtime_get_health");
215
+ return {
216
+ runtimeState: Number(health.runtime_state),
217
+ flags: Number(health.flags),
218
+ appliedGeneration: Number(health.applied_generation),
219
+ };
220
+ }
221
+ getStats(runtime) {
222
+ const stats = { struct_size: koffi.sizeof(RuntimeStatsStruct) };
223
+ this.requireOk(this.getStatsFn(runtime, stats), "runtime_get_stats");
224
+ return {
225
+ appliedGeneration: Number(stats.applied_generation),
226
+ routeCount: Number(stats.route_count),
227
+ runtimeState: Number(stats.runtime_state),
228
+ queueRejectedCount: Number(stats.queue_rejected_count),
229
+ routeMissCount: Number(stats.route_miss_count),
230
+ deadletterCount: Number(stats.deadletter_count),
231
+ deliveryFailedCount: Number(stats.delivery_failed_count),
232
+ controlRejectedCount: Number(stats.control_rejected_count),
233
+ monitorEventEmittedCount: Number(stats.monitor_event_emitted_count),
234
+ monitorEventDroppedCount: Number(stats.monitor_event_dropped_count),
235
+ monitorEventEmittedLifetimeCount: Number(stats.monitor_event_emitted_lifetime_count),
236
+ monitorEventDroppedLifetimeCount: Number(stats.monitor_event_dropped_lifetime_count),
237
+ localWorkQueueCapacity: Number(stats.local_work_queue_capacity),
238
+ localWorkQueueDepth: Number(stats.local_work_queue_depth),
239
+ localWorkQueueHighWatermark: Number(stats.local_work_queue_high_watermark),
240
+ deliveredRequestOutboundDirectWriteCount: Number(stats.delivered_request_outbound_direct_write_count),
241
+ responseOutboundDirectWriteCount: Number(stats.response_outbound_direct_write_count),
242
+ deadletterOutboundDirectWriteCount: Number(stats.deadletter_outbound_direct_write_count),
243
+ remoteOutboundQueueCapacity: Number(stats.remote_outbound_queue_capacity),
244
+ remoteOutboundQueueDepth: Number(stats.remote_outbound_queue_depth),
245
+ remoteOutboundQueueHighWatermark: Number(stats.remote_outbound_queue_high_watermark),
246
+ remoteOutboundQueueRejectedCount: Number(stats.remote_outbound_queue_rejected_count),
247
+ remoteOutboundExpiredDropCount: Number(stats.remote_outbound_expired_drop_count),
248
+ remoteOutboundReplyReserveSlots: Number(stats.remote_outbound_reply_reserve_slots),
249
+ remoteOutboundReplyReservationRejectCount: Number(stats.remote_outbound_reply_reservation_reject_count),
250
+ remoteOutboundOneWayDropCount: Number(stats.remote_outbound_one_way_drop_count),
251
+ };
252
+ }
253
+ getConfig(runtime) {
254
+ const config = { struct_size: koffi.sizeof(RuntimeConfigViewStruct) };
255
+ this.requireOk(this.getConfigFn(runtime, config), "runtime_get_config");
256
+ return {
257
+ systemName: decodeText(config.system_name),
258
+ nodeId: decodeText(config.node_id),
259
+ runtimeState: Number(config.runtime_state),
260
+ snapshotPresent: Number(config.snapshot_present) !== 0,
261
+ appliedGeneration: Number(config.applied_generation),
262
+ routeCount: Number(config.route_count),
263
+ southboundBindHost: decodeText(config.southbound_bind_host),
264
+ southboundBindPort: Number(config.southbound_bind_port),
265
+ effectiveIngressOverloadMode: Number(config.effective_ingress_overload_mode),
266
+ effectiveLocalDeliveryOverloadMode: Number(config.effective_local_delivery_overload_mode),
267
+ effectiveRemoteOutboundOverloadMode: Number(config.effective_remote_outbound_overload_mode),
268
+ effectiveRemoteOutboundReplyReserveSlots: Number(config.effective_remote_outbound_reply_reserve_slots),
269
+ };
270
+ }
271
+ submitEnvelope(runtime, bytes) {
272
+ this.requireOk(this.submitEnvelopeFn(runtime, bytes, bytes.byteLength), "submit_envelope");
273
+ }
274
+ applyControlEnvelope(runtime, bytes) {
275
+ this.requireOk(this.applyControlEnvelopeFn(runtime, bytes, bytes.byteLength), "apply_control_envelope");
276
+ }
277
+ requireOk(rc, what) {
278
+ if (rc !== COAKKA_OK) {
279
+ throw new Error(`${what} failed rc=${rc}`);
280
+ }
281
+ }
282
+ }
@@ -0,0 +1 @@
1
+
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "coakka-v2-connector-node",
3
+ "version": "1.3.1",
4
+ "description": "Node.js connector package for the CoAkka runtime v2",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "native",
12
+ "vendor",
13
+ "CONSUMING.md",
14
+ "LICENSE.md",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "prepare": "npm run build",
19
+ "build": "npm run stage:native && tsc -p tsconfig.build.json && node scripts/vendor-koffi.mjs",
20
+ "stage:native": "node scripts/stage-runtime-natives.mjs",
21
+ "test": "tsx --test test/**/*.test.ts",
22
+ "verify": "npm run build && npm test",
23
+ "pack:release": "npm run build && npm pack",
24
+ "smoke:packaged": "bash scripts/smoke-packaged-package.sh",
25
+ "demo:web": "tsx ../examples/node-jvm-order-demo/service_a.ts",
26
+ "benchmark": "node --import tsx ../examples/node-jvm-order-demo/benchmark.ts",
27
+ "benchmark:matrix": "node --import tsx ../examples/node-jvm-order-demo/benchmark_matrix.ts"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^24.0.0",
31
+ "koffi": "^2.16.1",
32
+ "tsx": "^4.21.0",
33
+ "typescript": "^5.8.3"
34
+ }
35
+ }
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the “Software”), to deal in
7
+ the Software without restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
+ Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.