mq-bridge 0.3.0 → 0.3.2

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/README.md CHANGED
@@ -24,7 +24,7 @@ npm run example
24
24
  ```ts
25
25
  import { Message, Route } from "mq-bridge";
26
26
 
27
- const route = Route.fromYamlStr(config, "orders");
27
+ const route = Route.fromStr(config, "orders");
28
28
 
29
29
  route.withHandler(async (message) => {
30
30
  const data = message.json();
@@ -39,3 +39,119 @@ route.start();
39
39
  ```
40
40
 
41
41
  Middleware is configured through the normal mq-bridge route config.
42
+
43
+ ## Loading config
44
+
45
+ The constructors mirror the Python bindings — the same capabilities are exposed
46
+ in both, with Node using camelCase names where Python uses snake_case:
47
+
48
+ - `Route.fromFile(path, name?)` loads from a YAML/JSON file
49
+ - `Route.fromStr(text, name?)` loads from an in-memory YAML/JSON string
50
+ - `Route.fromConfig(obj, name?)` loads from a JS object
51
+ - `Publisher.fromFile` / `Publisher.fromStr` / `Publisher.fromConfig` build a publisher endpoint
52
+
53
+ The `name` is optional: pass it to pick one entry out of a `routes:`/`publishers:`
54
+ document, or omit it to treat the whole config as a single bare route/endpoint body.
55
+ `fromYaml` / `fromYamlStr` remain as deprecated aliases for `fromFile` / `fromStr`.
56
+
57
+ ## Pull-based consumer
58
+
59
+ `Route` is push-based. To pull messages on your own schedule, use `Consumer`,
60
+ which wraps any input endpoint:
61
+
62
+ ```js
63
+ import { Consumer } from "mq-bridge";
64
+
65
+ const consumer = Consumer.fromConfig({ nats: { subject: "orders", url: "nats://localhost:4222" } });
66
+
67
+ while (!consumer.exhausted) {
68
+ const batch = await consumer.poll(500, 1000); // [] on timeout
69
+ if (batch.length === 0) continue;
70
+ for (const message of batch) handle(message.json());
71
+ await consumer.commit(); // ack only after handling
72
+ }
73
+ ```
74
+
75
+ `poll(max?, timeoutMs?)` returns up to `max` messages (default 256) without
76
+ acking, waiting up to `timeoutMs` milliseconds (omit it to block until a message
77
+ arrives); `commit()` acks every batch returned since the last commit. Committing
78
+ only after the downstream write succeeds gives at-least-once delivery. `exhausted`
79
+ turns `true` once a bounded source (e.g. a file) is drained; streaming brokers
80
+ never set it. `Consumer.fromFile` / `fromStr` accept a named entry under a
81
+ `consumers:` section or a single bare endpoint body.
82
+
83
+ `consumer.status()` resolves to a snapshot (`healthy`, `target`, `pending`,
84
+ `capacity`, `error`, `details`). `pending` is the broker backlog/lag where the
85
+ transport reports it (Kafka offset lag, AMQP queue depth, NATS JetStream
86
+ `numPending`), so `pending === 0` is a precise "caught up" check; it's absent
87
+ where the broker exposes no backlog (core NATS, MQTT). `consumer.close()`
88
+ releases the connection — idempotent, and `poll()`/`status()` reject afterwards.
89
+ Node is garbage-collected, so close explicitly rather than waiting for GC.
90
+
91
+ > **You must call `commit()` — it is not optional.** It is the only thing that
92
+ > tells the broker a batch is done. If you keep polling without committing, the
93
+ > offset never advances (every message is **re-delivered** on the next run), most
94
+ > brokers **stall** once their unacknowledged/prefetch window fills, and the
95
+ > uncommitted batches are held in memory so the process **grows unbounded**.
96
+ > Commit after each batch you have durably handled; to retry a failed batch,
97
+ > simply don't commit it.
98
+
99
+ ### Per-batch tokens: `pollBatch` / `ack` / `nack`
100
+
101
+ When you need to ack or release **specific** batches (rather than everything since
102
+ the last commit), use the token form. `pollBatch(max, timeoutMs)` resolves to
103
+ `{ messages, token }`; `ack(token)` commits just that batch, and `nack(token)`
104
+ releases it for redelivery (`nack()` with no argument nacks every outstanding
105
+ batch). This is the shape a [`dlt`](https://dlthub.com)-style loader wants — poll →
106
+ yield → load package commits → `ack(token)`.
107
+
108
+ ```js
109
+ const { messages, token } = await consumer.pollBatch(500, 1000); // token === null on timeout
110
+ if (token !== null) { // nothing returned on an idle timeout
111
+ // ... persist the batch downstream ...
112
+ await consumer.ack(token); // or consumer.nack(token) to redeliver
113
+ }
114
+ ```
115
+
116
+ Tokens stay outstanding until acked/nacked; `commit()` still acks every
117
+ outstanding batch at once, so don't mix the two styles on one consumer. On
118
+ cumulative-ack transports (Kafka), acking a later batch would implicitly ack the
119
+ earlier ones, so `ack(token)` must follow receive order — acking out of order
120
+ rejects; ack the oldest outstanding batch first, or use `commit()`. Transports
121
+ that ack each batch individually (NATS JetStream, AMQP, MQTT) accept any order.
122
+
123
+ > **At-least-once + idempotent merge.** Redelivery (after a nack, a missed
124
+ > `commit()`, or an expired broker ack deadline) means a record can arrive twice; a
125
+ > downstream loader must dedup on a stable key. `message.id` is globally unique per
126
+ > source position (Kafka `partition:offset`, NATS `stream_sequence`, AMQP delivery
127
+ > tag) and makes a natural primary key; source cursor fields are also available in
128
+ > `message.metadata` (`mqb.src.kafka_topic`/`mqb.src.kafka_offset`, `mqb.src.nats_subject`/`mqb.src.nats_stream_sequence`,
129
+ > `mqb.src.amqp_routing_key`/`mqb.src.amqp_delivery_tag`) when you opt in via the
130
+ > `MQB_SOURCE_METADATA=1` environment variable (off by default). Keep `batchSize × per-record cost` under
131
+ > the smallest broker ack deadline (JetStream `AckWait`, AMQP prefetch/timeout, MQTT
132
+ > inflight) or raise it in config. **Kafka has no per-message nack:** `nack` there
133
+ > leaves the offset unadvanced, so redelivery happens on the next run/rebalance.
134
+
135
+ ## Analysis
136
+
137
+ HTTP comparison benchmark, driven by a native load generator (`wrk`) so the
138
+ client is never the bottleneck. It boots each server in its own process — the
139
+ mq-bridge Node route plus raw Node `http`, uWebSockets.js, Fastify, and Express
140
+ (all peers run only when installed) — and drives each with `wrk`:
141
+
142
+ ```bash
143
+ cd node/mq-bridge-node
144
+ npm run build # release addon (the bench is meaningless on a debug build)
145
+ npm i -D fastify express # optional Node HTTP peers
146
+ npm i -D uNetworking/uWebSockets.js#v20.51.0 # the http-arena Node leader (native, from GitHub)
147
+ npm run bench:http -- --connections 1,8,32 --duration 8
148
+ ```
149
+
150
+ Requires `wrk` on `PATH` (`brew install wrk`). The `mqb` target needs the addon
151
+ built with the `http` feature (`npm run build` or `npm run build:ci`). Each
152
+ server echoes a tiny JSON body with `value` incremented; mq-bridge routes on the
153
+ `kind` header while the framework peers post plain JSON.
154
+
155
+ `uws` (uWebSockets.js) is the framework that tops public Node benchmarks like
156
+ http-arena and TechEmpower — it bypasses Node's `http` stack with a C++ socket
157
+ layer, so it is the most demanding yardstick here.
package/index.d.ts CHANGED
@@ -22,19 +22,97 @@ export class Message {
22
22
  }
23
23
 
24
24
  export class Publisher {
25
- static fromYaml(path: string, name: string): Publisher;
26
- static fromYamlStr(text: string, name: string): Publisher;
27
- static fromConfig(config: JsonValue, name: string): Publisher;
25
+ static fromFile(path: string, name?: string | null): Publisher;
26
+ static fromStr(text: string, name?: string | null): Publisher;
27
+ static fromConfig(config: JsonValue, name?: string | null): Publisher;
28
+ /** @deprecated Use {@link Publisher.fromFile} instead. */
29
+ static fromYaml(path: string, name?: string | null): Publisher;
30
+ /** @deprecated Use {@link Publisher.fromStr} instead. */
31
+ static fromYamlStr(text: string, name?: string | null): Publisher;
28
32
  send(message: Message): Promise<void>;
29
33
  request(message: Message): Promise<Message>;
30
34
  sendJson(data: JsonValue, metadata?: Metadata | null, id?: string | null): Promise<void>;
31
35
  requestJson(data: JsonValue, metadata?: Metadata | null, id?: string | null): Promise<Message>;
32
36
  }
33
37
 
38
+ export interface ConsumerStatus {
39
+ healthy: boolean;
40
+ target: string;
41
+ /** Broker backlog/lag where the transport reports it; absent otherwise. */
42
+ pending?: number;
43
+ capacity?: number;
44
+ error?: string;
45
+ details: JsonValue;
46
+ }
47
+
48
+ export class Consumer {
49
+ static fromFile(path: string, name?: string | null): Consumer;
50
+ static fromStr(text: string, name?: string | null): Consumer;
51
+ static fromConfig(config: JsonValue, name?: string | null): Consumer;
52
+ /**
53
+ * Receive up to `max` messages (default 256) without acking. Resolves to an
54
+ * empty array if `timeoutMs` milliseconds elapse with nothing received, or the
55
+ * source is exhausted. Omit `timeoutMs` to block until a message arrives. The
56
+ * returned messages are acked by the next `commit()` call — which you must
57
+ * call (see {@link Consumer.commit}).
58
+ */
59
+ poll(max?: number | null, timeoutMs?: number | null): Promise<Message[]>;
60
+ /**
61
+ * Like {@link Consumer.poll}, but also returns the batch's `token` so it can be
62
+ * acked or nacked individually with {@link Consumer.ack} / {@link Consumer.nack}
63
+ * — the shape a `dlt` resource wants (`poll → yield → commit load package →
64
+ * ack(token)`). `token` is `null` on timeout or end-of-stream. Tokens stay
65
+ * outstanding until acked/nacked; `commit()` still acks every outstanding batch
66
+ * at once, so don't mix the two styles on one consumer.
67
+ */
68
+ pollBatch(
69
+ max?: number | null,
70
+ timeoutMs?: number | null,
71
+ ): Promise<{ messages: Message[]; token: number | null }>;
72
+ /**
73
+ * Acknowledge every batch returned by `poll()` since the last `commit()`,
74
+ * advancing the consumer offset.
75
+ *
76
+ * Calling this is required, not optional. Without it the offset never advances
77
+ * (messages are re-delivered on the next run), most brokers stall once their
78
+ * unacknowledged/prefetch window fills, and uncommitted batches are held in
79
+ * memory so the process grows unbounded. To retry a failed batch, simply
80
+ * don't commit it — it will be redelivered.
81
+ */
82
+ commit(): Promise<void>;
83
+ /**
84
+ * Acknowledge a single batch by the `token` from {@link Consumer.pollBatch},
85
+ * advancing the consumer offset for just that batch. Rejects if the token is
86
+ * unknown (already acked/nacked, or never polled).
87
+ */
88
+ ack(token: number): Promise<void>;
89
+ /**
90
+ * Negatively acknowledge so the broker can redeliver. With a `token`, nacks
91
+ * just that batch; omit it to nack every outstanding batch (oldest first). On
92
+ * Kafka there is no per-message nack — this leaves the offset unadvanced, so
93
+ * redelivery happens on the next run/rebalance, not at once.
94
+ */
95
+ nack(token?: number | null): Promise<void>;
96
+ /**
97
+ * Status snapshot for the underlying endpoint. `pending === 0` is a precise
98
+ * "caught up" signal on transports that report backlog (Kafka, AMQP, NATS
99
+ * JetStream); `pending` is absent where the broker exposes none.
100
+ */
101
+ status(): Promise<ConsumerStatus>;
102
+ /** Release the broker connection. Idempotent; `poll()`/`status()` reject after. */
103
+ close(): Promise<void>;
104
+ /** `true` once the source has signalled end-of-stream (e.g. a drained file). */
105
+ get exhausted(): boolean;
106
+ }
107
+
34
108
  export class Route {
35
- static fromYaml(path: string, name: string): Route;
36
- static fromYamlStr(text: string, name: string): Route;
37
- static fromConfig(config: JsonValue, name: string): Route;
109
+ static fromFile(path: string, name?: string | null): Route;
110
+ static fromStr(text: string, name?: string | null): Route;
111
+ static fromConfig(config: JsonValue, name?: string | null): Route;
112
+ /** @deprecated Use {@link Route.fromFile} instead. */
113
+ static fromYaml(path: string, name?: string | null): Route;
114
+ /** @deprecated Use {@link Route.fromStr} instead. */
115
+ static fromYamlStr(text: string, name?: string | null): Route;
38
116
  withHandler(handler: MessageHandler): void;
39
117
  addHandler(kind: string, handler: JsonHandler): void;
40
118
  start(): void;
package/index.js CHANGED
@@ -57,18 +57,28 @@ class Publisher {
57
57
  this._native = nativePublisher;
58
58
  }
59
59
 
60
- static fromYaml(path, name) {
61
- return new Publisher(native.Publisher.fromYaml(path, name));
60
+ static fromFile(path, name) {
61
+ return new Publisher(native.Publisher.fromFile(path, name));
62
62
  }
63
63
 
64
- static fromYamlStr(text, name) {
65
- return new Publisher(native.Publisher.fromYamlStr(text, name));
64
+ static fromStr(text, name) {
65
+ return new Publisher(native.Publisher.fromStr(text, name));
66
66
  }
67
67
 
68
68
  static fromConfig(config, name) {
69
69
  return new Publisher(native.Publisher.fromConfig(config, name));
70
70
  }
71
71
 
72
+ /** @deprecated Use {@link Publisher.fromFile} instead. */
73
+ static fromYaml(path, name) {
74
+ return new Publisher(native.Publisher.fromFile(path, name));
75
+ }
76
+
77
+ /** @deprecated Use {@link Publisher.fromStr} instead. */
78
+ static fromYamlStr(text, name) {
79
+ return new Publisher(native.Publisher.fromStr(text, name));
80
+ }
81
+
72
82
  send(message) {
73
83
  return this._native.send(Message._toNative(message));
74
84
  }
@@ -86,23 +96,89 @@ class Publisher {
86
96
  }
87
97
  }
88
98
 
99
+ class Consumer {
100
+ constructor(nativeConsumer) {
101
+ this._native = nativeConsumer;
102
+ }
103
+
104
+ static fromFile(path, name) {
105
+ return new Consumer(native.Consumer.fromFile(path, name));
106
+ }
107
+
108
+ static fromStr(text, name) {
109
+ return new Consumer(native.Consumer.fromStr(text, name));
110
+ }
111
+
112
+ static fromConfig(config, name) {
113
+ return new Consumer(native.Consumer.fromConfig(config, name));
114
+ }
115
+
116
+ async poll(max, timeoutMs) {
117
+ const messages = await this._native.poll(max, timeoutMs);
118
+ return messages.map((message) => Message._fromNative(message));
119
+ }
120
+
121
+ async pollBatch(max, timeoutMs) {
122
+ const { messages, token } = await this._native.pollBatch(max, timeoutMs);
123
+ return {
124
+ messages: messages.map((message) => Message._fromNative(message)),
125
+ // Normalize the native `undefined` (no batch) to `null` per the typed API.
126
+ token: token ?? null,
127
+ };
128
+ }
129
+
130
+ commit() {
131
+ return this._native.commit();
132
+ }
133
+
134
+ ack(token) {
135
+ return this._native.ack(token);
136
+ }
137
+
138
+ nack(token) {
139
+ return this._native.nack(token);
140
+ }
141
+
142
+ status() {
143
+ return this._native.status();
144
+ }
145
+
146
+ close() {
147
+ return this._native.close();
148
+ }
149
+
150
+ get exhausted() {
151
+ return this._native.exhausted;
152
+ }
153
+ }
154
+
89
155
  class Route {
90
156
  constructor(nativeRoute) {
91
157
  this._native = nativeRoute;
92
158
  }
93
159
 
94
- static fromYaml(path, name) {
95
- return new Route(native.Route.fromYaml(path, name));
160
+ static fromFile(path, name) {
161
+ return new Route(native.Route.fromFile(path, name));
96
162
  }
97
163
 
98
- static fromYamlStr(text, name) {
99
- return new Route(native.Route.fromYamlStr(text, name));
164
+ static fromStr(text, name) {
165
+ return new Route(native.Route.fromStr(text, name));
100
166
  }
101
167
 
102
168
  static fromConfig(config, name) {
103
169
  return new Route(native.Route.fromConfig(config, name));
104
170
  }
105
171
 
172
+ /** @deprecated Use {@link Route.fromFile} instead. */
173
+ static fromYaml(path, name) {
174
+ return new Route(native.Route.fromFile(path, name));
175
+ }
176
+
177
+ /** @deprecated Use {@link Route.fromStr} instead. */
178
+ static fromYamlStr(text, name) {
179
+ return new Route(native.Route.fromStr(text, name));
180
+ }
181
+
106
182
  withHandler(handler) {
107
183
  this._native.withHandler(async (error, message) => {
108
184
  if (error) {
@@ -148,6 +224,7 @@ function configSchema() {
148
224
  module.exports = {
149
225
  Message,
150
226
  Publisher,
227
+ Consumer,
151
228
  Route,
152
229
  configSchema,
153
230
  version: native.VERSION,
package/native.d.ts CHANGED
@@ -1,9 +1,125 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ /**
4
+ * A pull-based consumer over any mq-bridge input endpoint.
5
+ *
6
+ * `poll()` receives a batch of messages but does **not** acknowledge them;
7
+ * call `commit()` once they have been durably handled to ack every batch
8
+ * returned since the previous commit (advancing offsets / removing them from
9
+ * the source). This manual-commit model gives at-least-once delivery across a
10
+ * failed downstream load. The endpoint config decides durability (consumer vs
11
+ * subscriber mode), exactly as it does for a route input.
12
+ *
13
+ * Relationship to the Rust core: this is a boundary-friendly projection of the
14
+ * core `MessageConsumer::receive_batch`, which is the low-level primitive. Two
15
+ * differences are deliberate, both because a Rust commit closure cannot be
16
+ * handed across the FFI boundary for JS to call later:
17
+ * - `receive_batch` returns the messages *and* their commit closure together;
18
+ * `poll()` returns only the messages and keeps the closure on the Rust side,
19
+ * so committing becomes the separate `commit()` call.
20
+ * - that closure accepts a per-message disposition vector (ack/nack/reject);
21
+ * `poll()` + `commit()` only ack the whole batch.
22
+ * `poll()` additionally layers a `timeoutMs` over `receive_batch` (which has no
23
+ * timeout of its own). Native Rust code should use `receive_batch` directly — it
24
+ * is strictly more expressive and needs no deferred-commit state.
25
+ */
26
+ export declare class Consumer {
27
+ /**
28
+ * Build a consumer from a YAML or JSON config file. Accepts a `consumers:`
29
+ * document entry (with `name`) or a single bare endpoint body.
30
+ */
31
+ static fromFile(path: string, name?: string | undefined | null): Consumer
32
+ /** Build a consumer from an in-memory YAML or JSON string. */
33
+ static fromStr(text: string, name?: string | undefined | null): Consumer
34
+ /**
35
+ * Build a consumer from an in-memory mapping (e.g. a JS object). Omit `name`
36
+ * to treat the mapping as a single bare endpoint body.
37
+ */
38
+ static fromConfig(config: JsonValue, name?: string | undefined | null): Consumer
39
+ /**
40
+ * Receive up to `max` messages without acking. Resolves to an empty array
41
+ * if `timeoutMs` milliseconds elapse with nothing received, or the source is
42
+ * exhausted (see `exhausted`). Omit `timeoutMs` to block until a message
43
+ * arrives. Acked by the next `commit()`.
44
+ */
45
+ poll(max?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<Array<NativeMessage>>
46
+ /**
47
+ * Like `poll()`, but also return the batch's token so it can be acked or
48
+ * nacked individually with `ack(token)` / `nack(token)` — the shape a `dlt`
49
+ * resource wants (`poll → yield → commit load package → ack(token)`).
50
+ * Resolves to `{ messages, token }`, with `token === null` on timeout or
51
+ * end-of-stream. Tokens stay outstanding until acked/nacked; `commit()`
52
+ * still acks every outstanding batch at once, so don't mix the two styles
53
+ * on one consumer.
54
+ */
55
+ pollBatch(max?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<PollBatch>
56
+ /**
57
+ * Acknowledge a single batch by the token from `pollBatch()`, advancing the
58
+ * consumer offset for just that batch. Rejects if the token is unknown
59
+ * (already acked/nacked, or never polled).
60
+ */
61
+ ack(token: number): Promise<void>
62
+ /**
63
+ * Negatively acknowledge so the broker can redeliver. With a `token`, nacks
64
+ * just that batch; without one, nacks every outstanding batch (oldest
65
+ * first). On Kafka there is no per-message nack — this leaves the offset
66
+ * unadvanced, so redelivery happens on the next run/rebalance, not at once.
67
+ */
68
+ nack(token?: number | undefined | null): Promise<void>
69
+ /**
70
+ * Acknowledge every batch returned by `poll()` since the last `commit()`,
71
+ * advancing the consumer offset.
72
+ *
73
+ * Calling this is required, not optional. Without it the offset never
74
+ * advances (messages are re-delivered on the next run), most brokers stall
75
+ * once their unacknowledged/prefetch window fills, and uncommitted batches
76
+ * are held in memory so the process grows unbounded. To retry a failed
77
+ * batch, simply don't commit it — it will be redelivered.
78
+ */
79
+ commit(): Promise<void>
80
+ /**
81
+ * `true` once the source has signalled end-of-stream (e.g. a fully drained
82
+ * file). Streaming brokers never set this.
83
+ */
84
+ get exhausted(): boolean
85
+ /**
86
+ * Resolve to a status snapshot for the underlying endpoint: `healthy`,
87
+ * `target`, optional `pending` (broker backlog/lag where the transport
88
+ * reports it — Kafka offset lag, AMQP queue depth, NATS JetStream
89
+ * `numPending`), optional `capacity`/`error`, and `details`. `pending === 0`
90
+ * is a precise "caught up" signal on those transports; it is absent where
91
+ * the broker exposes no backlog (core NATS, MQTT). Point-in-time snapshot.
92
+ */
93
+ status(): Promise<JsonValue>
94
+ /**
95
+ * Release the underlying consumer connection. Idempotent. After this,
96
+ * `poll()` and `status()` reject. GC'd JS has no deterministic drop, so
97
+ * closing explicitly is how the broker connection is freed promptly.
98
+ */
99
+ close(): Promise<void>
100
+ }
101
+
3
102
  export declare class Publisher {
4
- static fromYaml(path: string, name: string): Publisher
5
- static fromYamlStr(text: string, name: string): Publisher
6
- static fromConfig(config: JsonValue, name: string): Publisher
103
+ /**
104
+ * Build a publisher endpoint from a YAML or JSON config file. Omit `name`
105
+ * (or pass `""`) when the file is a single bare endpoint body.
106
+ */
107
+ static fromFile(path: string, name?: string | undefined | null): Publisher
108
+ /** Deprecated alias for `from_file`. */
109
+ static fromYaml(path: string, name?: string | undefined | null): Publisher
110
+ /**
111
+ * Build a publisher endpoint from an in-memory YAML or JSON string. Omit
112
+ * `name` (or pass `""`) when the string is a single bare endpoint body.
113
+ */
114
+ static fromStr(text: string, name?: string | undefined | null): Publisher
115
+ /** Deprecated alias for `from_str`. */
116
+ static fromYamlStr(text: string, name?: string | undefined | null): Publisher
117
+ /**
118
+ * Build a publisher endpoint from an in-memory mapping (e.g. a JS object).
119
+ * Omit `name` (or pass `""`) to treat the mapping as a single bare endpoint
120
+ * body.
121
+ */
122
+ static fromConfig(config: JsonValue, name?: string | undefined | null): Publisher
7
123
  send(message: NativeMessage): Promise<void>
8
124
  request(message: NativeMessage): Promise<NativeMessage>
9
125
  sendJson(data: JsonValue, metadata?: Record<string, string> | undefined | null, id?: string | undefined | null): Promise<void>
@@ -11,9 +127,29 @@ export declare class Publisher {
11
127
  }
12
128
 
13
129
  export declare class Route {
14
- static fromYaml(path: string, name: string): Route
15
- static fromYamlStr(text: string, name: string): Route
16
- static fromConfig(config: JsonValue, name: string): Route
130
+ /**
131
+ * Build a route from a YAML or JSON config file. Accepts a `routes:`
132
+ * document, a bare `{name: route}` map, or a single route body. Omit
133
+ * `name` (or pass `""`) when the file is a single bare route body.
134
+ */
135
+ static fromFile(path: string, name?: string | undefined | null): Route
136
+ /** Deprecated alias for `from_file`. */
137
+ static fromYaml(path: string, name?: string | undefined | null): Route
138
+ /**
139
+ * Build a route from an in-memory YAML or JSON string. Accepts the same
140
+ * shapes as `from_file`. Omit `name` (or pass `""`) when the string is a
141
+ * single bare route body.
142
+ */
143
+ static fromStr(text: string, name?: string | undefined | null): Route
144
+ /** Deprecated alias for `from_str`. */
145
+ static fromYamlStr(text: string, name?: string | undefined | null): Route
146
+ /**
147
+ * Build a route from an in-memory mapping (e.g. a JS object). Accepts a
148
+ * `routes:` document, a bare `{name: route}` map, or a single route body.
149
+ * Omit `name` (or pass `""`) to treat the mapping as a single bare route
150
+ * body, in which case a name is generated automatically.
151
+ */
152
+ static fromConfig(config: JsonValue, name?: string | undefined | null): Route
17
153
  withHandler(callback: ((err: Error | null, arg: NativeMessage) => Promise<NativeMessage | undefined | null>)): void
18
154
  addHandler(kind: string, callback: ((err: Error | null, arg: JsonValue) => Promise<NativeMessage | undefined | null>)): void
19
155
  start(): void
@@ -41,4 +177,11 @@ export interface NativeMessage {
41
177
  id?: string
42
178
  }
43
179
 
180
+ /** Result of `pollBatch()`: the messages plus the token used to `ack`/`nack` them. */
181
+ export interface PollBatch {
182
+ messages: Array<NativeMessage>
183
+ /** `null` when the poll timed out or the source is exhausted. */
184
+ token?: number
185
+ }
186
+
44
187
  export const version: string
package/native.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('mq-bridge-android-arm64')
79
79
  const bindingPackageVersion = require('mq-bridge-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('mq-bridge-android-arm-eabi')
95
95
  const bindingPackageVersion = require('mq-bridge-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('mq-bridge-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('mq-bridge-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('mq-bridge-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('mq-bridge-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('mq-bridge-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('mq-bridge-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('mq-bridge-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('mq-bridge-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('mq-bridge-darwin-universal')
184
184
  const bindingPackageVersion = require('mq-bridge-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('mq-bridge-darwin-x64')
200
200
  const bindingPackageVersion = require('mq-bridge-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('mq-bridge-darwin-arm64')
216
216
  const bindingPackageVersion = require('mq-bridge-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('mq-bridge-freebsd-x64')
236
236
  const bindingPackageVersion = require('mq-bridge-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('mq-bridge-freebsd-arm64')
252
252
  const bindingPackageVersion = require('mq-bridge-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('mq-bridge-linux-x64-musl')
273
273
  const bindingPackageVersion = require('mq-bridge-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('mq-bridge-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('mq-bridge-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('mq-bridge-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('mq-bridge-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('mq-bridge-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('mq-bridge-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('mq-bridge-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('mq-bridge-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('mq-bridge-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('mq-bridge-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('mq-bridge-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('mq-bridge-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('mq-bridge-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('mq-bridge-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('mq-bridge-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('mq-bridge-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('mq-bridge-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('mq-bridge-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('mq-bridge-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('mq-bridge-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('mq-bridge-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('mq-bridge-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('mq-bridge-openharmony-arm64')
478
478
  const bindingPackageVersion = require('mq-bridge-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('mq-bridge-openharmony-x64')
494
494
  const bindingPackageVersion = require('mq-bridge-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('mq-bridge-openharmony-arm')
510
510
  const bindingPackageVersion = require('mq-bridge-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.3.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.3.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -587,6 +587,7 @@ if (!nativeBinding) {
587
587
  }
588
588
 
589
589
  module.exports = nativeBinding
590
+ module.exports.Consumer = nativeBinding.Consumer
590
591
  module.exports.Publisher = nativeBinding.Publisher
591
592
  module.exports.Route = nativeBinding.Route
592
593
  module.exports.configSchema = nativeBinding.configSchema
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mq-bridge",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Node.js bindings for mq-bridge",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,17 +32,18 @@
32
32
  "build:ci": "napi build --platform --no-default-features --features \"http middleware schema\" --js native.js --dts native.d.ts",
33
33
  "build:debug": "napi build --platform --js native.js --dts native.d.ts",
34
34
  "example": "node examples/http-handler.js",
35
+ "bench:http": "node analysis/bench_http_native.js",
35
36
  "test": "node --test test/*.test.js",
36
37
  "sync-version": "node scripts/sync-version.mjs",
37
38
  "create-npm-dirs": "napi create-npm-dirs",
38
39
  "artifacts": "napi artifacts"
39
40
  },
40
41
  "optionalDependencies": {
41
- "mq-bridge-darwin-x64": "0.3.0",
42
- "mq-bridge-darwin-arm64": "0.3.0",
43
- "mq-bridge-linux-x64-gnu": "0.3.0",
44
- "mq-bridge-linux-arm64-gnu": "0.3.0",
45
- "mq-bridge-win32-x64-msvc": "0.3.0"
42
+ "mq-bridge-darwin-x64": "0.3.2",
43
+ "mq-bridge-darwin-arm64": "0.3.2",
44
+ "mq-bridge-linux-x64-gnu": "0.3.2",
45
+ "mq-bridge-linux-arm64-gnu": "0.3.2",
46
+ "mq-bridge-win32-x64-msvc": "0.3.2"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@napi-rs/cli": "^3.0.0"