@amqp-contract/core 0.24.0 → 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/dist/index.cjs +77 -2
- package/dist/index.d.cts +66 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +66 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +78 -4
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +144 -78
- package/package.json +3 -3
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:
|
|
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
|
|
|
@@ -46,7 +46,7 @@ await client.close();
|
|
|
46
46
|
new AmqpClient(contract, options): AmqpClient;
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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:
|
|
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:
|
|
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
|
|
|
@@ -117,7 +117,7 @@ This is useful for setting up channel-level configuration like prefetch.
|
|
|
117
117
|
cancel(consumerTag): ResultAsync<void, TechnicalError>;
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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
|
|
|
@@ -137,7 +137,7 @@ Cancel a consumer by its consumer tag.
|
|
|
137
137
|
close(): ResultAsync<void, TechnicalError>;
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
141
141
|
|
|
142
142
|
Close the channel and release the connection reference.
|
|
143
143
|
|
|
@@ -162,10 +162,22 @@ consume(
|
|
|
162
162
|
options?): ResultAsync<string, TechnicalError>;
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
166
166
|
|
|
167
167
|
Start consuming messages from a queue.
|
|
168
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
|
+
|
|
169
181
|
###### Parameters
|
|
170
182
|
|
|
171
183
|
| Parameter | Type |
|
|
@@ -186,7 +198,7 @@ ResultAsync resolving to the consumer tag.
|
|
|
186
198
|
getConnection(): IAmqpConnectionManager;
|
|
187
199
|
```
|
|
188
200
|
|
|
189
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
190
202
|
|
|
191
203
|
Get the underlying connection manager
|
|
192
204
|
|
|
@@ -209,7 +221,7 @@ nack(
|
|
|
209
221
|
requeue?): void;
|
|
210
222
|
```
|
|
211
223
|
|
|
212
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
213
225
|
|
|
214
226
|
Negative acknowledge a message.
|
|
215
227
|
|
|
@@ -231,7 +243,7 @@ Negative acknowledge a message.
|
|
|
231
243
|
on(event, listener): void;
|
|
232
244
|
```
|
|
233
245
|
|
|
234
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
235
247
|
|
|
236
248
|
Register an event listener on the channel wrapper.
|
|
237
249
|
|
|
@@ -261,7 +273,7 @@ publish(
|
|
|
261
273
|
options?): ResultAsync<boolean, TechnicalError>;
|
|
262
274
|
```
|
|
263
275
|
|
|
264
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
265
277
|
|
|
266
278
|
Publish a message to an exchange.
|
|
267
279
|
|
|
@@ -272,7 +284,7 @@ Publish a message to an exchange.
|
|
|
272
284
|
| `exchange` | `string` |
|
|
273
285
|
| `routingKey` | `string` |
|
|
274
286
|
| `content` | `unknown` |
|
|
275
|
-
| `options?` |
|
|
287
|
+
| `options?` | `Publish` |
|
|
276
288
|
|
|
277
289
|
###### Returns
|
|
278
290
|
|
|
@@ -289,7 +301,7 @@ sendToQueue(
|
|
|
289
301
|
options?): ResultAsync<boolean, TechnicalError>;
|
|
290
302
|
```
|
|
291
303
|
|
|
292
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
293
305
|
|
|
294
306
|
Publish a message directly to a queue.
|
|
295
307
|
|
|
@@ -299,7 +311,7 @@ Publish a message directly to a queue.
|
|
|
299
311
|
| ------ | ------ |
|
|
300
312
|
| `queue` | `string` |
|
|
301
313
|
| `content` | `unknown` |
|
|
302
|
-
| `options?` |
|
|
314
|
+
| `options?` | `Publish` |
|
|
303
315
|
|
|
304
316
|
###### Returns
|
|
305
317
|
|
|
@@ -313,7 +325,7 @@ ResultAsync resolving to `true` if the message was sent, `false` if the channel
|
|
|
313
325
|
waitForConnect(): ResultAsync<void, TechnicalError>;
|
|
314
326
|
```
|
|
315
327
|
|
|
316
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
317
329
|
|
|
318
330
|
Wait for the channel to be connected and ready.
|
|
319
331
|
|
|
@@ -336,7 +348,7 @@ automatically. The typed factories handle this cleanup for you.
|
|
|
336
348
|
|
|
337
349
|
### MessageValidationError
|
|
338
350
|
|
|
339
|
-
Defined in: [packages/core/src/errors.ts:33](https://github.com/btravers/amqp-contract/blob/
|
|
351
|
+
Defined in: [packages/core/src/errors.ts:33](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L33)
|
|
340
352
|
|
|
341
353
|
Error thrown when message validation fails (payload or headers).
|
|
342
354
|
|
|
@@ -363,7 +375,7 @@ The validation issues from the Standard Schema validation
|
|
|
363
375
|
new MessageValidationError(source, issues): MessageValidationError;
|
|
364
376
|
```
|
|
365
377
|
|
|
366
|
-
Defined in: [packages/core/src/errors.ts:34](https://github.com/btravers/amqp-contract/blob/
|
|
378
|
+
Defined in: [packages/core/src/errors.ts:34](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L34)
|
|
367
379
|
|
|
368
380
|
###### Parameters
|
|
369
381
|
|
|
@@ -387,10 +399,10 @@ Error.constructor
|
|
|
387
399
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
388
400
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
389
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 |
|
|
390
|
-
| <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/core/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
391
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 |
|
|
392
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 |
|
|
393
|
-
| <a id="source"></a> `source` | `readonly` | `string` | - | - | [packages/core/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
394
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 |
|
|
395
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 |
|
|
396
408
|
|
|
@@ -600,7 +612,7 @@ Error.prepareStackTrace
|
|
|
600
612
|
|
|
601
613
|
### TechnicalError
|
|
602
614
|
|
|
603
|
-
Defined in: [packages/core/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/
|
|
615
|
+
Defined in: [packages/core/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L7)
|
|
604
616
|
|
|
605
617
|
Error for technical/runtime failures that cannot be prevented by TypeScript.
|
|
606
618
|
|
|
@@ -619,7 +631,7 @@ and other runtime errors. This error is shared across core, worker, and client p
|
|
|
619
631
|
new TechnicalError(message, cause?): TechnicalError;
|
|
620
632
|
```
|
|
621
633
|
|
|
622
|
-
Defined in: [packages/core/src/errors.ts:8](https://github.com/btravers/amqp-contract/blob/
|
|
634
|
+
Defined in: [packages/core/src/errors.ts:8](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/errors.ts#L8)
|
|
623
635
|
|
|
624
636
|
###### Parameters
|
|
625
637
|
|
|
@@ -642,7 +654,7 @@ Error.constructor
|
|
|
642
654
|
|
|
643
655
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
644
656
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
645
|
-
| <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/core/src/errors.ts:10](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
646
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 |
|
|
647
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 |
|
|
648
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 |
|
|
@@ -858,7 +870,7 @@ Error.prepareStackTrace
|
|
|
858
870
|
type AmqpClientOptions = object;
|
|
859
871
|
```
|
|
860
872
|
|
|
861
|
-
Defined in: [packages/core/src/amqp-client.ts:73](https://github.com/btravers/amqp-contract/blob/
|
|
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)
|
|
862
874
|
|
|
863
875
|
Options for creating an AMQP client.
|
|
864
876
|
|
|
@@ -866,10 +878,10 @@ Options for creating an AMQP client.
|
|
|
866
878
|
|
|
867
879
|
| Property | Type | Description | Defined in |
|
|
868
880
|
| ------ | ------ | ------ | ------ |
|
|
869
|
-
| <a id="channeloptions"></a> `channelOptions?` | `Partial`<`CreateChannelOpts`> | Optional channel configuration options. | [packages/core/src/amqp-client.ts:76](https://github.com/btravers/amqp-contract/blob/
|
|
870
|
-
| <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/
|
|
871
|
-
| <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/
|
|
872
|
-
| <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/
|
|
881
|
+
| <a id="channeloptions"></a> `channelOptions?` | `Partial`<`CreateChannelOpts`> | 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) |
|
|
873
885
|
|
|
874
886
|
***
|
|
875
887
|
|
|
@@ -879,7 +891,7 @@ Options for creating an AMQP client.
|
|
|
879
891
|
type ConsumeCallback = (msg) => void | Promise<void>;
|
|
880
892
|
```
|
|
881
893
|
|
|
882
|
-
Defined in: [packages/core/src/amqp-client.ts:83](https://github.com/btravers/amqp-contract/blob/
|
|
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)
|
|
883
895
|
|
|
884
896
|
Callback type for consuming messages.
|
|
885
897
|
|
|
@@ -901,15 +913,23 @@ Callback type for consuming messages.
|
|
|
901
913
|
type ConsumerOptions = Options.Consume & object;
|
|
902
914
|
```
|
|
903
915
|
|
|
904
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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.
|
|
905
920
|
|
|
906
|
-
|
|
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.
|
|
907
927
|
|
|
908
928
|
#### Type Declaration
|
|
909
929
|
|
|
910
930
|
| Name | Type | Description | Defined in |
|
|
911
931
|
| ------ | ------ | ------ | ------ |
|
|
912
|
-
| `prefetch?` | `number` |
|
|
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) |
|
|
913
933
|
|
|
914
934
|
***
|
|
915
935
|
|
|
@@ -919,7 +939,7 @@ Consume options that extend amqplib's Options.Consume with optional prefetch sup
|
|
|
919
939
|
type Logger = object;
|
|
920
940
|
```
|
|
921
941
|
|
|
922
|
-
Defined in: [packages/core/src/logger.ts:30](https://github.com/btravers/amqp-contract/blob/
|
|
942
|
+
Defined in: [packages/core/src/logger.ts:30](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L30)
|
|
923
943
|
|
|
924
944
|
Logger interface for amqp-contract packages.
|
|
925
945
|
|
|
@@ -946,7 +966,7 @@ const logger: Logger = {
|
|
|
946
966
|
debug(message, context?): void;
|
|
947
967
|
```
|
|
948
968
|
|
|
949
|
-
Defined in: [packages/core/src/logger.ts:36](https://github.com/btravers/amqp-contract/blob/
|
|
969
|
+
Defined in: [packages/core/src/logger.ts:36](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L36)
|
|
950
970
|
|
|
951
971
|
Log debug level messages
|
|
952
972
|
|
|
@@ -967,7 +987,7 @@ Log debug level messages
|
|
|
967
987
|
error(message, context?): void;
|
|
968
988
|
```
|
|
969
989
|
|
|
970
|
-
Defined in: [packages/core/src/logger.ts:57](https://github.com/btravers/amqp-contract/blob/
|
|
990
|
+
Defined in: [packages/core/src/logger.ts:57](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L57)
|
|
971
991
|
|
|
972
992
|
Log error level messages
|
|
973
993
|
|
|
@@ -988,7 +1008,7 @@ Log error level messages
|
|
|
988
1008
|
info(message, context?): void;
|
|
989
1009
|
```
|
|
990
1010
|
|
|
991
|
-
Defined in: [packages/core/src/logger.ts:43](https://github.com/btravers/amqp-contract/blob/
|
|
1011
|
+
Defined in: [packages/core/src/logger.ts:43](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L43)
|
|
992
1012
|
|
|
993
1013
|
Log info level messages
|
|
994
1014
|
|
|
@@ -1009,7 +1029,7 @@ Log info level messages
|
|
|
1009
1029
|
warn(message, context?): void;
|
|
1010
1030
|
```
|
|
1011
1031
|
|
|
1012
|
-
Defined in: [packages/core/src/logger.ts:50](https://github.com/btravers/amqp-contract/blob/
|
|
1032
|
+
Defined in: [packages/core/src/logger.ts:50](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L50)
|
|
1013
1033
|
|
|
1014
1034
|
Log warning level messages
|
|
1015
1035
|
|
|
@@ -1032,7 +1052,7 @@ Log warning level messages
|
|
|
1032
1052
|
type LoggerContext = Record<string, unknown> & object;
|
|
1033
1053
|
```
|
|
1034
1054
|
|
|
1035
|
-
Defined in: [packages/core/src/logger.ts:9](https://github.com/btravers/amqp-contract/blob/
|
|
1055
|
+
Defined in: [packages/core/src/logger.ts:9](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L9)
|
|
1036
1056
|
|
|
1037
1057
|
Context object for logger methods.
|
|
1038
1058
|
|
|
@@ -1043,25 +1063,26 @@ for common logging context properties.
|
|
|
1043
1063
|
|
|
1044
1064
|
| Name | Type | Defined in |
|
|
1045
1065
|
| ------ | ------ | ------ |
|
|
1046
|
-
| `error?` | `unknown` | [packages/core/src/logger.ts:10](https://github.com/btravers/amqp-contract/blob/
|
|
1066
|
+
| `error?` | `unknown` | [packages/core/src/logger.ts:10](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/logger.ts#L10) |
|
|
1047
1067
|
|
|
1048
1068
|
***
|
|
1049
1069
|
|
|
1050
1070
|
### PublishOptions
|
|
1051
1071
|
|
|
1052
1072
|
```ts
|
|
1053
|
-
type PublishOptions = Options.Publish
|
|
1073
|
+
type PublishOptions = Options.Publish;
|
|
1054
1074
|
```
|
|
1055
1075
|
|
|
1056
|
-
Defined in: [packages/core/src/amqp-client.ts:
|
|
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)
|
|
1057
1077
|
|
|
1058
|
-
Publish options
|
|
1078
|
+
Publish options for `AmqpClient.publish` / `AmqpClient.sendToQueue`.
|
|
1059
1079
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
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.)
|
|
1065
1086
|
|
|
1066
1087
|
***
|
|
1067
1088
|
|
|
@@ -1071,7 +1092,7 @@ Publish options that extend amqplib's Options.Publish with optional timeout supp
|
|
|
1071
1092
|
type TelemetryProvider = object;
|
|
1072
1093
|
```
|
|
1073
1094
|
|
|
1074
|
-
Defined in: [packages/core/src/telemetry.ts:54](https://github.com/btravers/amqp-contract/blob/
|
|
1095
|
+
Defined in: [packages/core/src/telemetry.ts:54](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L54)
|
|
1075
1096
|
|
|
1076
1097
|
Telemetry provider for AMQP operations.
|
|
1077
1098
|
Uses lazy loading to gracefully handle cases where OpenTelemetry is not installed.
|
|
@@ -1080,12 +1101,12 @@ Uses lazy loading to gracefully handle cases where OpenTelemetry is not installe
|
|
|
1080
1101
|
|
|
1081
1102
|
| Property | Type | Description | Defined in |
|
|
1082
1103
|
| ------ | ------ | ------ | ------ |
|
|
1083
|
-
| <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/
|
|
1084
|
-
| <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/
|
|
1085
|
-
| <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/
|
|
1086
|
-
| <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/
|
|
1087
|
-
| <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/
|
|
1088
|
-
| <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/
|
|
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) |
|
|
1089
1110
|
|
|
1090
1111
|
## Variables
|
|
1091
1112
|
|
|
@@ -1095,7 +1116,7 @@ Uses lazy loading to gracefully handle cases where OpenTelemetry is not installe
|
|
|
1095
1116
|
const DEFAULT_CONNECT_TIMEOUT_MS: 30000 = 30_000;
|
|
1096
1117
|
```
|
|
1097
1118
|
|
|
1098
|
-
Defined in: [packages/core/src/amqp-client.ts:47](https://github.com/btravers/amqp-contract/blob/
|
|
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)
|
|
1099
1120
|
|
|
1100
1121
|
Default time `waitForConnect` will wait for the broker before erroring out.
|
|
1101
1122
|
Defaulting to a finite value (rather than waiting forever) means a fail-fast
|
|
@@ -1113,7 +1134,7 @@ delays to ~24.8 days and silently fires near-immediately on `Infinity`.
|
|
|
1113
1134
|
const defaultTelemetryProvider: TelemetryProvider;
|
|
1114
1135
|
```
|
|
1115
1136
|
|
|
1116
|
-
Defined in: [packages/core/src/telemetry.ts:229](https://github.com/btravers/amqp-contract/blob/
|
|
1137
|
+
Defined in: [packages/core/src/telemetry.ts:229](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L229)
|
|
1117
1138
|
|
|
1118
1139
|
Default telemetry provider that uses OpenTelemetry API if available.
|
|
1119
1140
|
|
|
@@ -1125,7 +1146,7 @@ Default telemetry provider that uses OpenTelemetry API if available.
|
|
|
1125
1146
|
const MessagingSemanticConventions: object;
|
|
1126
1147
|
```
|
|
1127
1148
|
|
|
1128
|
-
Defined in: [packages/core/src/telemetry.ts:26](https://github.com/btravers/amqp-contract/blob/
|
|
1149
|
+
Defined in: [packages/core/src/telemetry.ts:26](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L26)
|
|
1129
1150
|
|
|
1130
1151
|
Semantic conventions for AMQP messaging following OpenTelemetry standards.
|
|
1131
1152
|
|
|
@@ -1133,20 +1154,20 @@ Semantic conventions for AMQP messaging following OpenTelemetry standards.
|
|
|
1133
1154
|
|
|
1134
1155
|
| Name | Type | Default value | Defined in |
|
|
1135
1156
|
| ------ | ------ | ------ | ------ |
|
|
1136
|
-
| <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/
|
|
1137
|
-
| <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/
|
|
1138
|
-
| <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/
|
|
1139
|
-
| <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/
|
|
1140
|
-
| <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/
|
|
1141
|
-
| <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/
|
|
1142
|
-
| <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/
|
|
1143
|
-
| <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/
|
|
1144
|
-
| <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/
|
|
1145
|
-
| <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/
|
|
1146
|
-
| <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/
|
|
1147
|
-
| <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/
|
|
1148
|
-
| <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/
|
|
1149
|
-
| <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/
|
|
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) |
|
|
1150
1171
|
|
|
1151
1172
|
#### See
|
|
1152
1173
|
|
|
@@ -1160,7 +1181,7 @@ https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/
|
|
|
1160
1181
|
function endSpanError(span, error): void;
|
|
1161
1182
|
```
|
|
1162
1183
|
|
|
1163
|
-
Defined in: [packages/core/src/telemetry.ts:324](https://github.com/btravers/amqp-contract/blob/
|
|
1184
|
+
Defined in: [packages/core/src/telemetry.ts:324](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L324)
|
|
1164
1185
|
|
|
1165
1186
|
End a span with error status.
|
|
1166
1187
|
|
|
@@ -1183,7 +1204,7 @@ End a span with error status.
|
|
|
1183
1204
|
function endSpanSuccess(span): void;
|
|
1184
1205
|
```
|
|
1185
1206
|
|
|
1186
|
-
Defined in: [packages/core/src/telemetry.ts:309](https://github.com/btravers/amqp-contract/blob/
|
|
1207
|
+
Defined in: [packages/core/src/telemetry.ts:309](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L309)
|
|
1187
1208
|
|
|
1188
1209
|
End a span with success status.
|
|
1189
1210
|
|
|
@@ -1210,7 +1231,7 @@ function recordConsumeMetric(
|
|
|
1210
1231
|
durationMs): void;
|
|
1211
1232
|
```
|
|
1212
1233
|
|
|
1213
|
-
Defined in: [packages/core/src/telemetry.ts:368](https://github.com/btravers/amqp-contract/blob/
|
|
1234
|
+
Defined in: [packages/core/src/telemetry.ts:368](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L368)
|
|
1214
1235
|
|
|
1215
1236
|
Record a consume metric.
|
|
1216
1237
|
|
|
@@ -1236,7 +1257,7 @@ Record a consume metric.
|
|
|
1236
1257
|
function recordLateRpcReply(provider, reason): void;
|
|
1237
1258
|
```
|
|
1238
1259
|
|
|
1239
|
-
Defined in: [packages/core/src/telemetry.ts:398](https://github.com/btravers/amqp-contract/blob/
|
|
1260
|
+
Defined in: [packages/core/src/telemetry.ts:398](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L398)
|
|
1240
1261
|
|
|
1241
1262
|
Record an RPC reply that arrived after the caller stopped waiting.
|
|
1242
1263
|
|
|
@@ -1264,7 +1285,7 @@ function recordPublishMetric(
|
|
|
1264
1285
|
durationMs): void;
|
|
1265
1286
|
```
|
|
1266
1287
|
|
|
1267
|
-
Defined in: [packages/core/src/telemetry.ts:341](https://github.com/btravers/amqp-contract/blob/
|
|
1288
|
+
Defined in: [packages/core/src/telemetry.ts:341](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L341)
|
|
1268
1289
|
|
|
1269
1290
|
Record a publish metric.
|
|
1270
1291
|
|
|
@@ -1284,13 +1305,58 @@ Record a publish metric.
|
|
|
1284
1305
|
|
|
1285
1306
|
***
|
|
1286
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`<`unknown`, `E`>
|
|
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
|
+
|
|
1287
1353
|
### setupAmqpTopology()
|
|
1288
1354
|
|
|
1289
1355
|
```ts
|
|
1290
1356
|
function setupAmqpTopology(channel, contract): Promise<void>;
|
|
1291
1357
|
```
|
|
1292
1358
|
|
|
1293
|
-
Defined in: [packages/core/src/setup.ts:26](https://github.com/btravers/amqp-contract/blob/
|
|
1359
|
+
Defined in: [packages/core/src/setup.ts:26](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/setup.ts#L26)
|
|
1294
1360
|
|
|
1295
1361
|
Setup AMQP topology (exchanges, queues, and bindings) from a contract definition.
|
|
1296
1362
|
|
|
@@ -1338,7 +1404,7 @@ function startConsumeSpan(
|
|
|
1338
1404
|
attributes?): Span | undefined;
|
|
1339
1405
|
```
|
|
1340
1406
|
|
|
1341
|
-
Defined in: [packages/core/src/telemetry.ts:277](https://github.com/btravers/amqp-contract/blob/
|
|
1407
|
+
Defined in: [packages/core/src/telemetry.ts:277](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L277)
|
|
1342
1408
|
|
|
1343
1409
|
Create a span for a consume/process operation.
|
|
1344
1410
|
Returns undefined if OpenTelemetry is not available.
|
|
@@ -1368,7 +1434,7 @@ function startPublishSpan(
|
|
|
1368
1434
|
attributes?): Span | undefined;
|
|
1369
1435
|
```
|
|
1370
1436
|
|
|
1371
|
-
Defined in: [packages/core/src/telemetry.ts:242](https://github.com/btravers/amqp-contract/blob/
|
|
1437
|
+
Defined in: [packages/core/src/telemetry.ts:242](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/core/src/telemetry.ts#L242)
|
|
1372
1438
|
|
|
1373
1439
|
Create a span for a publish operation.
|
|
1374
1440
|
Returns undefined if OpenTelemetry is not available.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Core utilities for AMQP setup and management in amqp-contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"amqp-connection-manager": "5.0.0",
|
|
54
54
|
"amqplib": "0.10.9",
|
|
55
55
|
"neverthrow": "8.2.0",
|
|
56
|
-
"@amqp-contract/contract": "0.
|
|
56
|
+
"@amqp-contract/contract": "0.25.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@opentelemetry/api": "1.9.1",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"typescript": "6.0.3",
|
|
65
65
|
"vitest": "4.1.5",
|
|
66
66
|
"zod": "4.4.3",
|
|
67
|
+
"@amqp-contract/testing": "0.25.0",
|
|
67
68
|
"@amqp-contract/tsconfig": "0.1.0",
|
|
68
|
-
"@amqp-contract/testing": "0.24.0",
|
|
69
69
|
"@amqp-contract/typedoc": "0.1.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|