@amqp-contract/core 0.23.1 → 0.25.0

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/docs/index.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### AmqpClient
10
10
 
11
- Defined in: [packages/core/src/amqp-client.ts:129](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L129)
11
+ Defined in: [packages/core/src/amqp-client.ts:141](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L141)
12
12
 
13
13
  AMQP client that manages connections and channels with automatic topology setup.
14
14
 
@@ -18,7 +18,7 @@ This class handles:
18
18
  - Automatic AMQP topology setup (exchanges, queues, bindings) from contract
19
19
  - Channel creation with JSON serialization enabled by default
20
20
 
21
- All operations return `Future<Result<T, TechnicalError>>` for consistent error handling.
21
+ All operations return `ResultAsync<T, TechnicalError>` for consistent error handling.
22
22
 
23
23
  #### Example
24
24
 
@@ -28,14 +28,14 @@ const client = new AmqpClient(contract, {
28
28
  connectionOptions: { heartbeatIntervalInSeconds: 30 }
29
29
  });
30
30
 
31
- // Wait for connection
32
- await client.waitForConnect().resultToPromise();
31
+ // Wait for connection (ResultAsync is thenable)
32
+ await client.waitForConnect();
33
33
 
34
34
  // Publish a message
35
- const result = await client.publish('exchange', 'routingKey', { data: 'value' }).resultToPromise();
35
+ const result = await client.publish('exchange', 'routingKey', { data: 'value' });
36
36
 
37
37
  // Close when done
38
- await client.close().resultToPromise();
38
+ await client.close();
39
39
  ```
40
40
 
41
41
  #### Constructors
@@ -46,7 +46,7 @@ await client.close().resultToPromise();
46
46
  new AmqpClient(contract, options): AmqpClient;
47
47
  ```
48
48
 
49
- Defined in: [packages/core/src/amqp-client.ts:148](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L148)
49
+ Defined in: [packages/core/src/amqp-client.ts:169](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L169)
50
50
 
51
51
  Create a new AMQP client instance.
52
52
 
@@ -74,7 +74,7 @@ The client will automatically:
74
74
  ack(msg, allUpTo?): void;
75
75
  ```
76
76
 
77
- Defined in: [packages/core/src/amqp-client.ts:326](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L326)
77
+ Defined in: [packages/core/src/amqp-client.ts:426](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L426)
78
78
 
79
79
  Acknowledge a message.
80
80
 
@@ -95,7 +95,7 @@ Acknowledge a message.
95
95
  addSetup(setup): void;
96
96
  ```
97
97
 
98
- Defined in: [packages/core/src/amqp-client.ts:348](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L348)
98
+ Defined in: [packages/core/src/amqp-client.ts:448](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L448)
99
99
 
100
100
  Add a setup function to be called when the channel is created or reconnected.
101
101
 
@@ -114,32 +114,30 @@ This is useful for setting up channel-level configuration like prefetch.
114
114
  ##### cancel()
115
115
 
116
116
  ```ts
117
- cancel(consumerTag): Future<Result<void, TechnicalError>>;
117
+ cancel(consumerTag): ResultAsync<void, TechnicalError>;
118
118
  ```
119
119
 
120
- Defined in: [packages/core/src/amqp-client.ts:314](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L314)
120
+ Defined in: [packages/core/src/amqp-client.ts:395](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L395)
121
121
 
122
122
  Cancel a consumer by its consumer tag.
123
123
 
124
124
  ###### Parameters
125
125
 
126
- | Parameter | Type | Description |
127
- | ------ | ------ | ------ |
128
- | `consumerTag` | `string` | The consumer tag to cancel |
126
+ | Parameter | Type |
127
+ | ------ | ------ |
128
+ | `consumerTag` | `string` |
129
129
 
130
130
  ###### Returns
131
131
 
132
- `Future`&lt;`Result`&lt;`void`, [`TechnicalError`](#technicalerror)&gt;&gt;
133
-
134
- A Future that resolves when the consumer is cancelled
132
+ `ResultAsync`&lt;`void`, [`TechnicalError`](#technicalerror)&gt;
135
133
 
136
134
  ##### close()
137
135
 
138
136
  ```ts
139
- close(): Future<Result<void, TechnicalError>>;
137
+ close(): ResultAsync<void, TechnicalError>;
140
138
  ```
141
139
 
142
- Defined in: [packages/core/src/amqp-client.ts:377](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L377)
140
+ Defined in: [packages/core/src/amqp-client.ts:478](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L478)
143
141
 
144
142
  Close the channel and release the connection reference.
145
143
 
@@ -148,11 +146,12 @@ This will:
148
146
  - Decrease the reference count on the shared connection
149
147
  - Close the connection if this was the last client using it
150
148
 
151
- ###### Returns
149
+ Both steps run regardless of each other's outcome; if both fail, the
150
+ errors are wrapped in an AggregateError.
152
151
 
153
- `Future`&lt;`Result`&lt;`void`, [`TechnicalError`](#technicalerror)&gt;&gt;
152
+ ###### Returns
154
153
 
155
- A Future that resolves when the channel and connection are closed
154
+ `ResultAsync`&lt;`void`, [`TechnicalError`](#technicalerror)&gt;
156
155
 
157
156
  ##### consume()
158
157
 
@@ -160,26 +159,38 @@ A Future that resolves when the channel and connection are closed
160
159
  consume(
161
160
  queue,
162
161
  callback,
163
- options?): Future<Result<string, TechnicalError>>;
162
+ options?): ResultAsync<string, TechnicalError>;
164
163
  ```
165
164
 
166
- Defined in: [packages/core/src/amqp-client.ts:298](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L298)
165
+ Defined in: [packages/core/src/amqp-client.ts:321](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L321)
167
166
 
168
167
  Start consuming messages from a queue.
169
168
 
169
+ If `options.prefetch` is set, a per-consumer prefetch count is applied via
170
+ `channel.prefetch(count, false)` registered as a setup function on the
171
+ channel wrapper *before* the underlying `consume` call. Registering it via
172
+ `addSetup` ensures the prefetch is reapplied automatically on channel
173
+ reconnect; using `global=false` scopes it to subsequent consumers on the
174
+ channel (RabbitMQ semantics — opposite of intuition: `false` is per-
175
+ consumer, `true` is channel-wide).
176
+
177
+ `prefetch` is stripped from the options handed to `channelWrapper.consume`
178
+ because it is not a valid `amqplib` `Options.Consume` field — leaving it
179
+ in would just travel as a no-op key-value pair on the consume frame.
180
+
170
181
  ###### Parameters
171
182
 
172
- | Parameter | Type | Description |
173
- | ------ | ------ | ------ |
174
- | `queue` | `string` | The queue name |
175
- | `callback` | [`ConsumeCallback`](#consumecallback) | The callback to invoke for each message |
176
- | `options?` | [`ConsumerOptions`](#consumeroptions) | Optional consume options |
183
+ | Parameter | Type |
184
+ | ------ | ------ |
185
+ | `queue` | `string` |
186
+ | `callback` | [`ConsumeCallback`](#consumecallback) |
187
+ | `options?` | [`ConsumerOptions`](#consumeroptions) |
177
188
 
178
189
  ###### Returns
179
190
 
180
- `Future`&lt;`Result`&lt;`string`, [`TechnicalError`](#technicalerror)&gt;&gt;
191
+ `ResultAsync`&lt;`string`, [`TechnicalError`](#technicalerror)&gt;
181
192
 
182
- A Future with `Result<string>` - the consumer tag
193
+ ResultAsync resolving to the consumer tag.
183
194
 
184
195
  ##### getConnection()
185
196
 
@@ -187,7 +198,7 @@ A Future with `Result<string>` - the consumer tag
187
198
  getConnection(): IAmqpConnectionManager;
188
199
  ```
189
200
 
190
- Defined in: [packages/core/src/amqp-client.ts:203](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L203)
201
+ Defined in: [packages/core/src/amqp-client.ts:224](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L224)
191
202
 
192
203
  Get the underlying connection manager
193
204
 
@@ -210,7 +221,7 @@ nack(
210
221
  requeue?): void;
211
222
  ```
212
223
 
213
- Defined in: [packages/core/src/amqp-client.ts:337](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L337)
224
+ Defined in: [packages/core/src/amqp-client.ts:437](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L437)
214
225
 
215
226
  Negative acknowledge a message.
216
227
 
@@ -232,7 +243,7 @@ Negative acknowledge a message.
232
243
  on(event, listener): void;
233
244
  ```
234
245
 
235
- Defined in: [packages/core/src/amqp-client.ts:363](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L363)
246
+ Defined in: [packages/core/src/amqp-client.ts:463](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L463)
236
247
 
237
248
  Register an event listener on the channel wrapper.
238
249
 
@@ -259,27 +270,27 @@ publish(
259
270
  exchange,
260
271
  routingKey,
261
272
  content,
262
- options?): Future<Result<boolean, TechnicalError>>;
273
+ options?): ResultAsync<boolean, TechnicalError>;
263
274
  ```
264
275
 
265
- Defined in: [packages/core/src/amqp-client.ts:261](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L261)
276
+ Defined in: [packages/core/src/amqp-client.ts:276](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L276)
266
277
 
267
278
  Publish a message to an exchange.
268
279
 
269
280
  ###### Parameters
270
281
 
271
- | Parameter | Type | Description |
272
- | ------ | ------ | ------ |
273
- | `exchange` | `string` | The exchange name |
274
- | `routingKey` | `string` | The routing key |
275
- | `content` | `unknown` | The message content (will be JSON serialized if json: true) |
276
- | `options?` | [`PublishOptions`](#publishoptions) | Optional publish options |
282
+ | Parameter | Type |
283
+ | ------ | ------ |
284
+ | `exchange` | `string` |
285
+ | `routingKey` | `string` |
286
+ | `content` | `unknown` |
287
+ | `options?` | `Publish` |
277
288
 
278
289
  ###### Returns
279
290
 
280
- `Future`&lt;`Result`&lt;`boolean`, [`TechnicalError`](#technicalerror)&gt;&gt;
291
+ `ResultAsync`&lt;`boolean`, [`TechnicalError`](#technicalerror)&gt;
281
292
 
282
- A Future with `Result<boolean>` - true if message was sent, false if channel buffer is full
293
+ ResultAsync resolving to `true` if the message was sent, `false` if the channel buffer is full.
283
294
 
284
295
  ##### sendToQueue()
285
296
 
@@ -287,39 +298,39 @@ A Future with `Result<boolean>` - true if message was sent, false if channel buf
287
298
  sendToQueue(
288
299
  queue,
289
300
  content,
290
- options?): Future<Result<boolean, TechnicalError>>;
301
+ options?): ResultAsync<boolean, TechnicalError>;
291
302
  ```
292
303
 
293
- Defined in: [packages/core/src/amqp-client.ts:280](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L280)
304
+ Defined in: [packages/core/src/amqp-client.ts:293](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L293)
294
305
 
295
306
  Publish a message directly to a queue.
296
307
 
297
308
  ###### Parameters
298
309
 
299
- | Parameter | Type | Description |
300
- | ------ | ------ | ------ |
301
- | `queue` | `string` | The queue name |
302
- | `content` | `unknown` | The message content (will be JSON serialized if json: true) |
303
- | `options?` | [`PublishOptions`](#publishoptions) | Optional publish options |
310
+ | Parameter | Type |
311
+ | ------ | ------ |
312
+ | `queue` | `string` |
313
+ | `content` | `unknown` |
314
+ | `options?` | `Publish` |
304
315
 
305
316
  ###### Returns
306
317
 
307
- `Future`&lt;`Result`&lt;`boolean`, [`TechnicalError`](#technicalerror)&gt;&gt;
318
+ `ResultAsync`&lt;`boolean`, [`TechnicalError`](#technicalerror)&gt;
308
319
 
309
- A Future with `Result<boolean>` - true if message was sent, false if channel buffer is full
320
+ ResultAsync resolving to `true` if the message was sent, `false` if the channel buffer is full.
310
321
 
311
322
  ##### waitForConnect()
312
323
 
313
324
  ```ts
314
- waitForConnect(): Future<Result<void, TechnicalError>>;
325
+ waitForConnect(): ResultAsync<void, TechnicalError>;
315
326
  ```
316
327
 
317
- Defined in: [packages/core/src/amqp-client.ts:224](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L224)
328
+ Defined in: [packages/core/src/amqp-client.ts:242](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L242)
318
329
 
319
330
  Wait for the channel to be connected and ready.
320
331
 
321
332
  If `connectTimeoutMs` was provided in the constructor options, the returned
322
- Future resolves to `Result.Error<TechnicalError>` once the timeout elapses.
333
+ ResultAsync resolves to `err(TechnicalError)` once the timeout elapses.
323
334
  Without a timeout, this waits forever — amqp-connection-manager retries
324
335
  connections indefinitely and never errors on its own.
325
336
 
@@ -331,16 +342,13 @@ automatically. The typed factories handle this cleanup for you.
331
342
 
332
343
  ###### Returns
333
344
 
334
- `Future`&lt;`Result`&lt;`void`, [`TechnicalError`](#technicalerror)&gt;&gt;
335
-
336
- A Future resolving to `Result.Ok(void)` on connect, or
337
- `Result.Error(TechnicalError)` on timeout / connection failure.
345
+ `ResultAsync`&lt;`void`, [`TechnicalError`](#technicalerror)&gt;
338
346
 
339
347
  ***
340
348
 
341
349
  ### MessageValidationError
342
350
 
343
- Defined in: [packages/core/src/errors.ts:33](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L33)
351
+ Defined in: [packages/core/src/errors.ts:33](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L33)
344
352
 
345
353
  Error thrown when message validation fails (payload or headers).
346
354
 
@@ -367,7 +375,7 @@ The validation issues from the Standard Schema validation
367
375
  new MessageValidationError(source, issues): MessageValidationError;
368
376
  ```
369
377
 
370
- Defined in: [packages/core/src/errors.ts:34](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L34)
378
+ Defined in: [packages/core/src/errors.ts:34](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L34)
371
379
 
372
380
  ###### Parameters
373
381
 
@@ -391,10 +399,10 @@ Error.constructor
391
399
  | Property | Modifier | Type | Description | Inherited from | Defined in |
392
400
  | ------ | ------ | ------ | ------ | ------ | ------ |
393
401
  | <a id="cause"></a> `cause?` | `public` | `unknown` | - | `Error.cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
394
- | <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/core/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L36) |
402
+ | <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/core/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L36) |
395
403
  | <a id="message"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
396
404
  | <a id="name"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
397
- | <a id="source"></a> `source` | `readonly` | `string` | - | - | [packages/core/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L35) |
405
+ | <a id="source"></a> `source` | `readonly` | `string` | - | - | [packages/core/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L35) |
398
406
  | <a id="stack"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
399
407
  | <a id="stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.6.0/node\_modules/@types/node/globals.d.ts:67 |
400
408
 
@@ -604,7 +612,7 @@ Error.prepareStackTrace
604
612
 
605
613
  ### TechnicalError
606
614
 
607
- Defined in: [packages/core/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L7)
615
+ Defined in: [packages/core/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L7)
608
616
 
609
617
  Error for technical/runtime failures that cannot be prevented by TypeScript.
610
618
 
@@ -623,7 +631,7 @@ and other runtime errors. This error is shared across core, worker, and client p
623
631
  new TechnicalError(message, cause?): TechnicalError;
624
632
  ```
625
633
 
626
- Defined in: [packages/core/src/errors.ts:8](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L8)
634
+ Defined in: [packages/core/src/errors.ts:8](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L8)
627
635
 
628
636
  ###### Parameters
629
637
 
@@ -646,7 +654,7 @@ Error.constructor
646
654
 
647
655
  | Property | Modifier | Type | Description | Inherited from | Defined in |
648
656
  | ------ | ------ | ------ | ------ | ------ | ------ |
649
- | <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/core/src/errors.ts:10](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/errors.ts#L10) |
657
+ | <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/core/src/errors.ts:10](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L10) |
650
658
  | <a id="message-1"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
651
659
  | <a id="name-1"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
652
660
  | <a id="stack-1"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
@@ -862,7 +870,7 @@ Error.prepareStackTrace
862
870
  type AmqpClientOptions = object;
863
871
  ```
864
872
 
865
- Defined in: [packages/core/src/amqp-client.ts:73](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L73)
873
+ Defined in: [packages/core/src/amqp-client.ts:73](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L73)
866
874
 
867
875
  Options for creating an AMQP client.
868
876
 
@@ -870,10 +878,10 @@ Options for creating an AMQP client.
870
878
 
871
879
  | Property | Type | Description | Defined in |
872
880
  | ------ | ------ | ------ | ------ |
873
- | <a id="channeloptions"></a> `channelOptions?` | `Partial`&lt;`CreateChannelOpts`&gt; | Optional channel configuration options. | [packages/core/src/amqp-client.ts:76](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L76) |
874
- | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.). | [packages/core/src/amqp-client.ts:75](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L75) |
875
- | <a id="connecttimeoutms"></a> `connectTimeoutMs?` | `number` \| `null` | Maximum time in ms to wait for the channel to become ready in `waitForConnect`. Defaults to [DEFAULT\_CONNECT\_TIMEOUT\_MS](#default_connect_timeout_ms). Pass `null` to disable the timeout entirely (amqp-connection-manager will retry indefinitely). | [packages/core/src/amqp-client.ts:77](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L77) |
876
- | <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support. | [packages/core/src/amqp-client.ts:74](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L74) |
881
+ | <a id="channeloptions"></a> `channelOptions?` | `Partial`&lt;`CreateChannelOpts`&gt; | Optional channel configuration options. | [packages/core/src/amqp-client.ts:76](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L76) |
882
+ | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.). | [packages/core/src/amqp-client.ts:75](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L75) |
883
+ | <a id="connecttimeoutms"></a> `connectTimeoutMs?` | `number` \| `null` | Maximum time in ms to wait for the channel to become ready in `waitForConnect`. Defaults to [DEFAULT\_CONNECT\_TIMEOUT\_MS](#default_connect_timeout_ms). Pass `null` to disable the timeout entirely (amqp-connection-manager will retry indefinitely). | [packages/core/src/amqp-client.ts:77](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L77) |
884
+ | <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support. | [packages/core/src/amqp-client.ts:74](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L74) |
877
885
 
878
886
  ***
879
887
 
@@ -883,7 +891,7 @@ Options for creating an AMQP client.
883
891
  type ConsumeCallback = (msg) => void | Promise<void>;
884
892
  ```
885
893
 
886
- Defined in: [packages/core/src/amqp-client.ts:83](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L83)
894
+ Defined in: [packages/core/src/amqp-client.ts:83](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L83)
887
895
 
888
896
  Callback type for consuming messages.
889
897
 
@@ -905,15 +913,23 @@ Callback type for consuming messages.
905
913
  type ConsumerOptions = Options.Consume & object;
906
914
  ```
907
915
 
908
- Defined in: [packages/core/src/amqp-client.ts:96](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L96)
916
+ Defined in: [packages/core/src/amqp-client.ts:108](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L108)
917
+
918
+ Consume options that extend amqplib's `Options.Consume` with an optional
919
+ per-consumer prefetch count.
909
920
 
910
- Consume options that extend amqplib's Options.Consume with optional prefetch support.
921
+ `prefetch` is intercepted by [AmqpClient.consume](#consume): it is stripped from
922
+ the options handed to the underlying `channelWrapper.consume(...)` call
923
+ (since amqplib's `Options.Consume` does not include it) and applied via
924
+ `channel.prefetch(count, false)` registered through `addSetup` *before* the
925
+ consume so the value is in effect when the consumer starts and is reapplied
926
+ automatically on channel reconnect.
911
927
 
912
928
  #### Type Declaration
913
929
 
914
930
  | Name | Type | Description | Defined in |
915
931
  | ------ | ------ | ------ | ------ |
916
- | `prefetch?` | `number` | Number of messages to prefetch | [packages/core/src/amqp-client.ts:98](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L98) |
932
+ | `prefetch?` | `number` | Per-consumer prefetch count. Applied before `channel.consume(...)`. | [packages/core/src/amqp-client.ts:110](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L110) |
917
933
 
918
934
  ***
919
935
 
@@ -923,7 +939,7 @@ Consume options that extend amqplib's Options.Consume with optional prefetch sup
923
939
  type Logger = object;
924
940
  ```
925
941
 
926
- Defined in: [packages/core/src/logger.ts:30](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L30)
942
+ Defined in: [packages/core/src/logger.ts:30](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L30)
927
943
 
928
944
  Logger interface for amqp-contract packages.
929
945
 
@@ -950,7 +966,7 @@ const logger: Logger = {
950
966
  debug(message, context?): void;
951
967
  ```
952
968
 
953
- Defined in: [packages/core/src/logger.ts:36](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L36)
969
+ Defined in: [packages/core/src/logger.ts:36](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L36)
954
970
 
955
971
  Log debug level messages
956
972
 
@@ -971,7 +987,7 @@ Log debug level messages
971
987
  error(message, context?): void;
972
988
  ```
973
989
 
974
- Defined in: [packages/core/src/logger.ts:57](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L57)
990
+ Defined in: [packages/core/src/logger.ts:57](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L57)
975
991
 
976
992
  Log error level messages
977
993
 
@@ -992,7 +1008,7 @@ Log error level messages
992
1008
  info(message, context?): void;
993
1009
  ```
994
1010
 
995
- Defined in: [packages/core/src/logger.ts:43](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L43)
1011
+ Defined in: [packages/core/src/logger.ts:43](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L43)
996
1012
 
997
1013
  Log info level messages
998
1014
 
@@ -1013,7 +1029,7 @@ Log info level messages
1013
1029
  warn(message, context?): void;
1014
1030
  ```
1015
1031
 
1016
- Defined in: [packages/core/src/logger.ts:50](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L50)
1032
+ Defined in: [packages/core/src/logger.ts:50](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L50)
1017
1033
 
1018
1034
  Log warning level messages
1019
1035
 
@@ -1036,7 +1052,7 @@ Log warning level messages
1036
1052
  type LoggerContext = Record<string, unknown> & object;
1037
1053
  ```
1038
1054
 
1039
- Defined in: [packages/core/src/logger.ts:9](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L9)
1055
+ Defined in: [packages/core/src/logger.ts:9](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L9)
1040
1056
 
1041
1057
  Context object for logger methods.
1042
1058
 
@@ -1047,25 +1063,26 @@ for common logging context properties.
1047
1063
 
1048
1064
  | Name | Type | Defined in |
1049
1065
  | ------ | ------ | ------ |
1050
- | `error?` | `unknown` | [packages/core/src/logger.ts:10](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/logger.ts#L10) |
1066
+ | `error?` | `unknown` | [packages/core/src/logger.ts:10](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L10) |
1051
1067
 
1052
1068
  ***
1053
1069
 
1054
1070
  ### PublishOptions
1055
1071
 
1056
1072
  ```ts
1057
- type PublishOptions = Options.Publish & object;
1073
+ type PublishOptions = Options.Publish;
1058
1074
  ```
1059
1075
 
1060
- Defined in: [packages/core/src/amqp-client.ts:88](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L88)
1061
-
1062
- Publish options that extend amqplib's Options.Publish with optional timeout support.
1076
+ Defined in: [packages/core/src/amqp-client.ts:95](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L95)
1063
1077
 
1064
- #### Type Declaration
1078
+ Publish options for `AmqpClient.publish` / `AmqpClient.sendToQueue`.
1065
1079
 
1066
- | Name | Type | Description | Defined in |
1067
- | ------ | ------ | ------ | ------ |
1068
- | `timeout?` | `number` | Message will be rejected after timeout ms | [packages/core/src/amqp-client.ts:90](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L90) |
1080
+ Currently a re-export of amqplib's `Options.Publish`. A previous version of
1081
+ this type also exposed a `timeout` field, but that field never had a
1082
+ meaningful AMQP-level effect in this codebase and has been removed to avoid
1083
+ suggesting behaviour we do not provide. (`amqp-connection-manager`'s own
1084
+ `publishTimeout` channel option is unrelated and is configured at channel
1085
+ creation, not per-publish.)
1069
1086
 
1070
1087
  ***
1071
1088
 
@@ -1075,7 +1092,7 @@ Publish options that extend amqplib's Options.Publish with optional timeout supp
1075
1092
  type TelemetryProvider = object;
1076
1093
  ```
1077
1094
 
1078
- Defined in: [packages/core/src/telemetry.ts:54](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L54)
1095
+ Defined in: [packages/core/src/telemetry.ts:54](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L54)
1079
1096
 
1080
1097
  Telemetry provider for AMQP operations.
1081
1098
  Uses lazy loading to gracefully handle cases where OpenTelemetry is not installed.
@@ -1084,12 +1101,12 @@ Uses lazy loading to gracefully handle cases where OpenTelemetry is not installe
1084
1101
 
1085
1102
  | Property | Type | Description | Defined in |
1086
1103
  | ------ | ------ | ------ | ------ |
1087
- | <a id="getconsumecounter"></a> `getConsumeCounter` | () => `Counter` \| `undefined` | Get a counter for messages consumed. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:71](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L71) |
1088
- | <a id="getconsumelatencyhistogram"></a> `getConsumeLatencyHistogram` | () => `Histogram` \| `undefined` | Get a histogram for consume/process latency. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:83](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L83) |
1089
- | <a id="getlaterpcreplycounter"></a> `getLateRpcReplyCounter` | () => `Counter` \| `undefined` | Get a counter for RPC replies that arrive after the caller has gone away (timeout, cancellation, or unknown correlationId). Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:90](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L90) |
1090
- | <a id="getpublishcounter"></a> `getPublishCounter` | () => `Counter` \| `undefined` | Get a counter for messages published. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:65](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L65) |
1091
- | <a id="getpublishlatencyhistogram"></a> `getPublishLatencyHistogram` | () => `Histogram` \| `undefined` | Get a histogram for publish latency. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:77](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L77) |
1092
- | <a id="gettracer"></a> `getTracer` | () => `Tracer` \| `undefined` | Get a tracer instance for creating spans. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:59](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L59) |
1104
+ | <a id="getconsumecounter"></a> `getConsumeCounter` | () => `Counter` \| `undefined` | Get a counter for messages consumed. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:71](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L71) |
1105
+ | <a id="getconsumelatencyhistogram"></a> `getConsumeLatencyHistogram` | () => `Histogram` \| `undefined` | Get a histogram for consume/process latency. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:83](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L83) |
1106
+ | <a id="getlaterpcreplycounter"></a> `getLateRpcReplyCounter` | () => `Counter` \| `undefined` | Get a counter for RPC replies that arrive after the caller has gone away (timeout, cancellation, or unknown correlationId). Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:90](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L90) |
1107
+ | <a id="getpublishcounter"></a> `getPublishCounter` | () => `Counter` \| `undefined` | Get a counter for messages published. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:65](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L65) |
1108
+ | <a id="getpublishlatencyhistogram"></a> `getPublishLatencyHistogram` | () => `Histogram` \| `undefined` | Get a histogram for publish latency. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:77](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L77) |
1109
+ | <a id="gettracer"></a> `getTracer` | () => `Tracer` \| `undefined` | Get a tracer instance for creating spans. Returns undefined if OpenTelemetry is not available. | [packages/core/src/telemetry.ts:59](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L59) |
1093
1110
 
1094
1111
  ## Variables
1095
1112
 
@@ -1099,12 +1116,12 @@ Uses lazy loading to gracefully handle cases where OpenTelemetry is not installe
1099
1116
  const DEFAULT_CONNECT_TIMEOUT_MS: 30000 = 30_000;
1100
1117
  ```
1101
1118
 
1102
- Defined in: [packages/core/src/amqp-client.ts:47](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/amqp-client.ts#L47)
1119
+ Defined in: [packages/core/src/amqp-client.ts:47](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/amqp-client.ts#L47)
1103
1120
 
1104
1121
  Default time `waitForConnect` will wait for the broker before erroring out.
1105
1122
  Defaulting to a finite value (rather than waiting forever) means a fail-fast
1106
1123
  developer experience: a misconfigured URL, a down broker, or wrong
1107
- credentials surface as a Result.Error within 30 seconds. Pass `null`
1124
+ credentials surface as an `err` within 30 seconds. Pass `null`
1108
1125
  explicitly to disable the timeout — `Infinity` and other non-finite values
1109
1126
  are also coerced to "no timeout" because Node's `setTimeout` clamps large
1110
1127
  delays to ~24.8 days and silently fires near-immediately on `Infinity`.
@@ -1117,7 +1134,7 @@ delays to ~24.8 days and silently fires near-immediately on `Infinity`.
1117
1134
  const defaultTelemetryProvider: TelemetryProvider;
1118
1135
  ```
1119
1136
 
1120
- Defined in: [packages/core/src/telemetry.ts:229](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L229)
1137
+ Defined in: [packages/core/src/telemetry.ts:229](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L229)
1121
1138
 
1122
1139
  Default telemetry provider that uses OpenTelemetry API if available.
1123
1140
 
@@ -1129,7 +1146,7 @@ Default telemetry provider that uses OpenTelemetry API if available.
1129
1146
  const MessagingSemanticConventions: object;
1130
1147
  ```
1131
1148
 
1132
- Defined in: [packages/core/src/telemetry.ts:26](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L26)
1149
+ Defined in: [packages/core/src/telemetry.ts:26](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L26)
1133
1150
 
1134
1151
  Semantic conventions for AMQP messaging following OpenTelemetry standards.
1135
1152
 
@@ -1137,20 +1154,20 @@ Semantic conventions for AMQP messaging following OpenTelemetry standards.
1137
1154
 
1138
1155
  | Name | Type | Default value | Defined in |
1139
1156
  | ------ | ------ | ------ | ------ |
1140
- | <a id="property-amqp_consumer_name"></a> `AMQP_CONSUMER_NAME` | `"amqp.consumer.name"` | `"amqp.consumer.name"` | [packages/core/src/telemetry.ts:37](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L37) |
1141
- | <a id="property-amqp_publisher_name"></a> `AMQP_PUBLISHER_NAME` | `"amqp.publisher.name"` | `"amqp.publisher.name"` | [packages/core/src/telemetry.ts:36](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L36) |
1142
- | <a id="property-error_type"></a> `ERROR_TYPE` | `"error.type"` | `"error.type"` | [packages/core/src/telemetry.ts:40](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L40) |
1143
- | <a id="property-messaging_destination"></a> `MESSAGING_DESTINATION` | `"messaging.destination.name"` | `"messaging.destination.name"` | [packages/core/src/telemetry.ts:29](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L29) |
1144
- | <a id="property-messaging_destination_kind"></a> `MESSAGING_DESTINATION_KIND` | `"messaging.destination.kind"` | `"messaging.destination.kind"` | [packages/core/src/telemetry.ts:30](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L30) |
1145
- | <a id="property-messaging_destination_kind_exchange"></a> `MESSAGING_DESTINATION_KIND_EXCHANGE` | `"exchange"` | `"exchange"` | [packages/core/src/telemetry.ts:44](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L44) |
1146
- | <a id="property-messaging_destination_kind_queue"></a> `MESSAGING_DESTINATION_KIND_QUEUE` | `"queue"` | `"queue"` | [packages/core/src/telemetry.ts:45](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L45) |
1147
- | <a id="property-messaging_operation"></a> `MESSAGING_OPERATION` | `"messaging.operation"` | `"messaging.operation"` | [packages/core/src/telemetry.ts:31](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L31) |
1148
- | <a id="property-messaging_operation_process"></a> `MESSAGING_OPERATION_PROCESS` | `"process"` | `"process"` | [packages/core/src/telemetry.ts:47](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L47) |
1149
- | <a id="property-messaging_operation_publish"></a> `MESSAGING_OPERATION_PUBLISH` | `"publish"` | `"publish"` | [packages/core/src/telemetry.ts:46](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L46) |
1150
- | <a id="property-messaging_rabbitmq_message_delivery_tag"></a> `MESSAGING_RABBITMQ_MESSAGE_DELIVERY_TAG` | `"messaging.rabbitmq.message.delivery_tag"` | `"messaging.rabbitmq.message.delivery_tag"` | [packages/core/src/telemetry.ts:35](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L35) |
1151
- | <a id="property-messaging_rabbitmq_routing_key"></a> `MESSAGING_RABBITMQ_ROUTING_KEY` | `"messaging.rabbitmq.destination.routing_key"` | `"messaging.rabbitmq.destination.routing_key"` | [packages/core/src/telemetry.ts:34](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L34) |
1152
- | <a id="property-messaging_system"></a> `MESSAGING_SYSTEM` | `"messaging.system"` | `"messaging.system"` | [packages/core/src/telemetry.ts:28](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L28) |
1153
- | <a id="property-messaging_system_rabbitmq"></a> `MESSAGING_SYSTEM_RABBITMQ` | `"rabbitmq"` | `"rabbitmq"` | [packages/core/src/telemetry.ts:43](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L43) |
1157
+ | <a id="property-amqp_consumer_name"></a> `AMQP_CONSUMER_NAME` | `"amqp.consumer.name"` | `"amqp.consumer.name"` | [packages/core/src/telemetry.ts:37](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L37) |
1158
+ | <a id="property-amqp_publisher_name"></a> `AMQP_PUBLISHER_NAME` | `"amqp.publisher.name"` | `"amqp.publisher.name"` | [packages/core/src/telemetry.ts:36](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L36) |
1159
+ | <a id="property-error_type"></a> `ERROR_TYPE` | `"error.type"` | `"error.type"` | [packages/core/src/telemetry.ts:40](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L40) |
1160
+ | <a id="property-messaging_destination"></a> `MESSAGING_DESTINATION` | `"messaging.destination.name"` | `"messaging.destination.name"` | [packages/core/src/telemetry.ts:29](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L29) |
1161
+ | <a id="property-messaging_destination_kind"></a> `MESSAGING_DESTINATION_KIND` | `"messaging.destination.kind"` | `"messaging.destination.kind"` | [packages/core/src/telemetry.ts:30](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L30) |
1162
+ | <a id="property-messaging_destination_kind_exchange"></a> `MESSAGING_DESTINATION_KIND_EXCHANGE` | `"exchange"` | `"exchange"` | [packages/core/src/telemetry.ts:44](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L44) |
1163
+ | <a id="property-messaging_destination_kind_queue"></a> `MESSAGING_DESTINATION_KIND_QUEUE` | `"queue"` | `"queue"` | [packages/core/src/telemetry.ts:45](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L45) |
1164
+ | <a id="property-messaging_operation"></a> `MESSAGING_OPERATION` | `"messaging.operation"` | `"messaging.operation"` | [packages/core/src/telemetry.ts:31](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L31) |
1165
+ | <a id="property-messaging_operation_process"></a> `MESSAGING_OPERATION_PROCESS` | `"process"` | `"process"` | [packages/core/src/telemetry.ts:47](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L47) |
1166
+ | <a id="property-messaging_operation_publish"></a> `MESSAGING_OPERATION_PUBLISH` | `"publish"` | `"publish"` | [packages/core/src/telemetry.ts:46](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L46) |
1167
+ | <a id="property-messaging_rabbitmq_message_delivery_tag"></a> `MESSAGING_RABBITMQ_MESSAGE_DELIVERY_TAG` | `"messaging.rabbitmq.message.delivery_tag"` | `"messaging.rabbitmq.message.delivery_tag"` | [packages/core/src/telemetry.ts:35](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L35) |
1168
+ | <a id="property-messaging_rabbitmq_routing_key"></a> `MESSAGING_RABBITMQ_ROUTING_KEY` | `"messaging.rabbitmq.destination.routing_key"` | `"messaging.rabbitmq.destination.routing_key"` | [packages/core/src/telemetry.ts:34](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L34) |
1169
+ | <a id="property-messaging_system"></a> `MESSAGING_SYSTEM` | `"messaging.system"` | `"messaging.system"` | [packages/core/src/telemetry.ts:28](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L28) |
1170
+ | <a id="property-messaging_system_rabbitmq"></a> `MESSAGING_SYSTEM_RABBITMQ` | `"rabbitmq"` | `"rabbitmq"` | [packages/core/src/telemetry.ts:43](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L43) |
1154
1171
 
1155
1172
  #### See
1156
1173
 
@@ -1164,7 +1181,7 @@ https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/
1164
1181
  function endSpanError(span, error): void;
1165
1182
  ```
1166
1183
 
1167
- Defined in: [packages/core/src/telemetry.ts:324](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L324)
1184
+ Defined in: [packages/core/src/telemetry.ts:324](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L324)
1168
1185
 
1169
1186
  End a span with error status.
1170
1187
 
@@ -1187,7 +1204,7 @@ End a span with error status.
1187
1204
  function endSpanSuccess(span): void;
1188
1205
  ```
1189
1206
 
1190
- Defined in: [packages/core/src/telemetry.ts:309](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L309)
1207
+ Defined in: [packages/core/src/telemetry.ts:309](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L309)
1191
1208
 
1192
1209
  End a span with success status.
1193
1210
 
@@ -1214,7 +1231,7 @@ function recordConsumeMetric(
1214
1231
  durationMs): void;
1215
1232
  ```
1216
1233
 
1217
- Defined in: [packages/core/src/telemetry.ts:368](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L368)
1234
+ Defined in: [packages/core/src/telemetry.ts:368](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L368)
1218
1235
 
1219
1236
  Record a consume metric.
1220
1237
 
@@ -1240,7 +1257,7 @@ Record a consume metric.
1240
1257
  function recordLateRpcReply(provider, reason): void;
1241
1258
  ```
1242
1259
 
1243
- Defined in: [packages/core/src/telemetry.ts:398](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L398)
1260
+ Defined in: [packages/core/src/telemetry.ts:398](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L398)
1244
1261
 
1245
1262
  Record an RPC reply that arrived after the caller stopped waiting.
1246
1263
 
@@ -1268,7 +1285,7 @@ function recordPublishMetric(
1268
1285
  durationMs): void;
1269
1286
  ```
1270
1287
 
1271
- Defined in: [packages/core/src/telemetry.ts:341](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L341)
1288
+ Defined in: [packages/core/src/telemetry.ts:341](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L341)
1272
1289
 
1273
1290
  Record a publish metric.
1274
1291
 
@@ -1288,13 +1305,58 @@ Record a publish metric.
1288
1305
 
1289
1306
  ***
1290
1307
 
1308
+ ### safeJsonParse()
1309
+
1310
+ ```ts
1311
+ function safeJsonParse<E>(buffer, errorFn): Result<unknown, E>;
1312
+ ```
1313
+
1314
+ Defined in: [packages/core/src/parsing.ts:24](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/parsing.ts#L24)
1315
+
1316
+ Parse a `Buffer` as JSON, mapping any `JSON.parse` exception to the
1317
+ caller-supplied error type.
1318
+
1319
+ Use this in consume / reply paths where a parse failure is a typed value,
1320
+ not a thrown exception — the caller decides how to translate the raw error
1321
+ into a domain-level error (e.g. [TechnicalError](#technicalerror)).
1322
+
1323
+ #### Type Parameters
1324
+
1325
+ | Type Parameter | Description |
1326
+ | ------ | ------ |
1327
+ | `E` | The error type produced by `errorFn`. |
1328
+
1329
+ #### Parameters
1330
+
1331
+ | Parameter | Type | Description |
1332
+ | ------ | ------ | ------ |
1333
+ | `buffer` | `Buffer` | The raw message body to parse. |
1334
+ | `errorFn` | (`raw`) => `E` | Callback invoked with the underlying `JSON.parse` error. |
1335
+
1336
+ #### Returns
1337
+
1338
+ `Result`&lt;`unknown`, `E`&gt;
1339
+
1340
+ A `Result` containing the parsed `unknown` value or the mapped error.
1341
+
1342
+ #### Example
1343
+
1344
+ ```typescript
1345
+ const parsed = safeJsonParse(
1346
+ msg.content,
1347
+ (error) => new TechnicalError("Failed to parse JSON", error),
1348
+ );
1349
+ ```
1350
+
1351
+ ***
1352
+
1291
1353
  ### setupAmqpTopology()
1292
1354
 
1293
1355
  ```ts
1294
1356
  function setupAmqpTopology(channel, contract): Promise<void>;
1295
1357
  ```
1296
1358
 
1297
- Defined in: [packages/core/src/setup.ts:26](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/setup.ts#L26)
1359
+ Defined in: [packages/core/src/setup.ts:26](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/setup.ts#L26)
1298
1360
 
1299
1361
  Setup AMQP topology (exchanges, queues, and bindings) from a contract definition.
1300
1362
 
@@ -1342,7 +1404,7 @@ function startConsumeSpan(
1342
1404
  attributes?): Span | undefined;
1343
1405
  ```
1344
1406
 
1345
- Defined in: [packages/core/src/telemetry.ts:277](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L277)
1407
+ Defined in: [packages/core/src/telemetry.ts:277](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L277)
1346
1408
 
1347
1409
  Create a span for a consume/process operation.
1348
1410
  Returns undefined if OpenTelemetry is not available.
@@ -1372,7 +1434,7 @@ function startPublishSpan(
1372
1434
  attributes?): Span | undefined;
1373
1435
  ```
1374
1436
 
1375
- Defined in: [packages/core/src/telemetry.ts:242](https://github.com/btravers/amqp-contract/blob/dc096282cd7249a6b8148d35c3dfad011c9e9753/packages/core/src/telemetry.ts#L242)
1437
+ Defined in: [packages/core/src/telemetry.ts:242](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L242)
1376
1438
 
1377
1439
  Create a span for a publish operation.
1378
1440
  Returns undefined if OpenTelemetry is not available.