@zdavison/matador 2.0.3 → 2.0.4
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/core/matador.d.ts +2 -2
- package/dist/core/matador.d.ts.map +1 -1
- package/dist/core/matador.js +1 -0
- package/dist/index.cjs +44 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/pipeline.d.ts +4 -1
- package/dist/pipeline/pipeline.d.ts.map +1 -1
- package/dist/pipeline/pipeline.js +16 -4
- package/dist/pipeline/pipeline.test.js +15 -1
- package/dist/topology/builder.d.ts.map +1 -1
- package/dist/topology/builder.js +2 -1
- package/dist/topology/builder.test.js +68 -0
- package/dist/topology/index.d.ts +2 -2
- package/dist/topology/index.d.ts.map +1 -1
- package/dist/topology/index.js +1 -1
- package/dist/topology/types.d.ts +53 -1
- package/dist/topology/types.d.ts.map +1 -1
- package/dist/topology/types.js +10 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -1
- package/dist/transport/rabbitmq/rabbitmq-transport.js +30 -22
- package/dist/transport/rabbitmq/rabbitmq-transport.test.js +1 -1
- package/dist/types/dispatcher.d.ts +14 -0
- package/dist/types/dispatcher.d.ts.map +1 -0
- package/dist/types/dispatcher.js +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/subscriber.d.ts +20 -4
- package/dist/types/subscriber.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/matador.ts +3 -1
- package/src/index.ts +9 -0
- package/src/pipeline/pipeline.test.ts +24 -2
- package/src/pipeline/pipeline.ts +28 -6
- package/src/topology/builder.test.ts +90 -0
- package/src/topology/builder.ts +2 -1
- package/src/topology/index.ts +4 -0
- package/src/topology/types.ts +75 -1
- package/src/transport/rabbitmq/rabbitmq-transport.test.ts +1 -1
- package/src/transport/rabbitmq/rabbitmq-transport.ts +33 -25
- package/src/types/dispatcher.ts +18 -0
- package/src/types/index.ts +4 -0
- package/src/types/subscriber.ts +22 -3
- package/test/e2e/rabbitmq-transport.e2e.test.ts +287 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -4,7 +4,7 @@ import type { SafeHooks } from '../hooks/index.js';
|
|
|
4
4
|
import type { RetryDecision, RetryPolicy } from '../retry/index.js';
|
|
5
5
|
import type { SchemaRegistry } from '../schema/index.js';
|
|
6
6
|
import type { MessageReceipt, Transport } from '../transport/index.js';
|
|
7
|
-
import type { Envelope, SubscriberDefinition } from '../types/index.js';
|
|
7
|
+
import type { Dispatcher, Envelope, SubscriberDefinition } from '../types/index.js';
|
|
8
8
|
/**
|
|
9
9
|
* Configuration for the processing pipeline.
|
|
10
10
|
*/
|
|
@@ -16,6 +16,8 @@ export interface PipelineConfig {
|
|
|
16
16
|
readonly hooks: SafeHooks;
|
|
17
17
|
/** Optional checkpoint store for resumable subscribers */
|
|
18
18
|
readonly checkpointStore?: CheckpointStore | undefined;
|
|
19
|
+
/** Dispatcher (matador) for sending events from subscriber callbacks */
|
|
20
|
+
readonly dispatcher: Dispatcher;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Result of pipeline processing.
|
|
@@ -44,6 +46,7 @@ export declare class ProcessingPipeline {
|
|
|
44
46
|
private readonly retryPolicy;
|
|
45
47
|
private readonly hooks;
|
|
46
48
|
private readonly checkpointStore;
|
|
49
|
+
private readonly dispatcher;
|
|
47
50
|
constructor(config: PipelineConfig);
|
|
48
51
|
/**
|
|
49
52
|
* Processes a raw message from the transport.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,KA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;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,MAAM,EAAE,cAAc;IAUlC;;OAEG;IACG,OAAO,CACX,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC;YA4NX,mBAAmB;YAqCnB,gBAAgB;IAkB9B;;;OAGG;IACH,OAAO,CAAC,yBAAyB;CA+BlC"}
|
|
@@ -18,6 +18,7 @@ export class ProcessingPipeline {
|
|
|
18
18
|
retryPolicy;
|
|
19
19
|
hooks;
|
|
20
20
|
checkpointStore;
|
|
21
|
+
dispatcher;
|
|
21
22
|
constructor(config) {
|
|
22
23
|
this.transport = config.transport;
|
|
23
24
|
this.schema = config.schema;
|
|
@@ -25,6 +26,7 @@ export class ProcessingPipeline {
|
|
|
25
26
|
this.retryPolicy = config.retryPolicy;
|
|
26
27
|
this.hooks = config.hooks;
|
|
27
28
|
this.checkpointStore = config.checkpointStore ?? new NoOpCheckpointStore();
|
|
29
|
+
this.dispatcher = config.dispatcher;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Processes a raw message from the transport.
|
|
@@ -113,19 +115,29 @@ export class ProcessingPipeline {
|
|
|
113
115
|
},
|
|
114
116
|
});
|
|
115
117
|
}
|
|
118
|
+
// Create base callback context with matador dispatcher
|
|
119
|
+
const callbackContext = { matador: this.dispatcher };
|
|
116
120
|
await this.hooks.onWorkerWrap(envelope, subscriberDef, async () => {
|
|
117
121
|
await this.hooks.onWorkerBeforeProcess(envelope, subscriberDef);
|
|
118
122
|
try {
|
|
119
123
|
if (isResumable && context) {
|
|
120
|
-
// Resumable subscriber: pass context
|
|
124
|
+
// Resumable subscriber: pass combined context (checkpoint + matador)
|
|
121
125
|
// Cast needed because TypeScript can't narrow the union type based on isResumable
|
|
122
126
|
const resumableCallback = subscriber.callback;
|
|
123
|
-
|
|
127
|
+
// Create combined context by binding class methods and adding matador
|
|
128
|
+
const fullContext = {
|
|
129
|
+
io: context.io.bind(context),
|
|
130
|
+
all: context.all.bind(context),
|
|
131
|
+
attempt: context.attempt,
|
|
132
|
+
isRetry: context.isRetry,
|
|
133
|
+
matador: this.dispatcher,
|
|
134
|
+
};
|
|
135
|
+
result = await resumableCallback(envelope, fullContext);
|
|
124
136
|
}
|
|
125
137
|
else {
|
|
126
|
-
// Standard subscriber:
|
|
138
|
+
// Standard subscriber: pass envelope and callback context
|
|
127
139
|
const standardCallback = subscriber.callback;
|
|
128
|
-
result = await standardCallback(envelope);
|
|
140
|
+
result = await standardCallback(envelope, callbackContext);
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
catch (e) {
|
|
@@ -255,7 +255,11 @@ describe('ProcessingPipeline', () => {
|
|
|
255
255
|
const receipt = createReceipt();
|
|
256
256
|
const result = await pipeline.process(new Uint8Array(), receipt);
|
|
257
257
|
expect(result.success).toBe(true);
|
|
258
|
-
expect(callbackMock).
|
|
258
|
+
expect(callbackMock).toHaveBeenCalledTimes(1);
|
|
259
|
+
// Callback receives envelope as first argument and context (with matador) as second
|
|
260
|
+
const calls = callbackMock.mock.calls;
|
|
261
|
+
expect(calls[0][0]).toEqual(envelope);
|
|
262
|
+
expect(calls[0][1]).toHaveProperty('matador');
|
|
259
263
|
});
|
|
260
264
|
it('should handle callback throwing error', async () => {
|
|
261
265
|
const envelope = createTestEnvelope();
|
|
@@ -1027,12 +1031,22 @@ function createMockConfig(overrides = {}) {
|
|
|
1027
1031
|
onDecodeError: async () => { },
|
|
1028
1032
|
...overrides.hooks,
|
|
1029
1033
|
};
|
|
1034
|
+
const defaultDispatcher = {
|
|
1035
|
+
send: mock(async () => ({
|
|
1036
|
+
eventKey: 'test.event',
|
|
1037
|
+
subscribersSent: 0,
|
|
1038
|
+
subscribersSkipped: 0,
|
|
1039
|
+
errors: [],
|
|
1040
|
+
})),
|
|
1041
|
+
...overrides.dispatcher,
|
|
1042
|
+
};
|
|
1030
1043
|
return {
|
|
1031
1044
|
transport: defaultTransport,
|
|
1032
1045
|
schema: { ...defaultSchema, ...overrides.schema },
|
|
1033
1046
|
codec: defaultCodec,
|
|
1034
1047
|
retryPolicy: defaultRetryPolicy,
|
|
1035
1048
|
hooks: defaultHooks,
|
|
1049
|
+
dispatcher: defaultDispatcher,
|
|
1036
1050
|
};
|
|
1037
1051
|
}
|
|
1038
1052
|
function createTestEnvelope() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/topology/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,MA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OAGG;IACH,KAAK,IAAI,QAAQ;CAgBlB"}
|
package/dist/topology/builder.js
CHANGED
|
@@ -119,7 +119,8 @@ export class TopologyBuilder {
|
|
|
119
119
|
if (!queue.name || queue.name.trim() === '') {
|
|
120
120
|
issues.push('Queue name cannot be empty');
|
|
121
121
|
}
|
|
122
|
-
else if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(queue.name)) {
|
|
122
|
+
else if (!queue.exact && !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(queue.name)) {
|
|
123
|
+
// Skip pattern validation for exact queues (allows names like 'matador.shared.id-platform')
|
|
123
124
|
issues.push(`Queue name "${queue.name}" must start with a letter and contain only alphanumeric characters, underscores, and hyphens`);
|
|
124
125
|
}
|
|
125
126
|
else if (queueNames.has(queue.name)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
2
|
import { TopologyBuilder, TopologyValidationError } from './builder.js';
|
|
3
|
+
import { resolveQueueName } from './types.js';
|
|
3
4
|
describe('TopologyBuilder', () => {
|
|
4
5
|
describe('withNamespace', () => {
|
|
5
6
|
it('should set the namespace', () => {
|
|
@@ -218,6 +219,44 @@ describe('TopologyBuilder', () => {
|
|
|
218
219
|
.build();
|
|
219
220
|
expect(topology.queues[0]?.exact).toBe(true);
|
|
220
221
|
});
|
|
222
|
+
it('should allow dots in queue name when exact: true', () => {
|
|
223
|
+
const topology = TopologyBuilder.create()
|
|
224
|
+
.withNamespace('test')
|
|
225
|
+
.addQueue('matador.shared.id-platform', { exact: true })
|
|
226
|
+
.build();
|
|
227
|
+
expect(topology.queues[0]?.name).toBe('matador.shared.id-platform');
|
|
228
|
+
expect(topology.queues[0]?.exact).toBe(true);
|
|
229
|
+
});
|
|
230
|
+
it('should reject dots in queue name when exact: false', () => {
|
|
231
|
+
const builder = TopologyBuilder.create()
|
|
232
|
+
.withNamespace('test')
|
|
233
|
+
.addQueue('invalid.queue.name');
|
|
234
|
+
expect(() => builder.build()).toThrow('must start with a letter');
|
|
235
|
+
});
|
|
236
|
+
it('should allow transport-specific RabbitMQ options with exact queue', () => {
|
|
237
|
+
const topology = TopologyBuilder.create()
|
|
238
|
+
.withNamespace('test')
|
|
239
|
+
.addQueue('matador.shared.id-platform', {
|
|
240
|
+
exact: true,
|
|
241
|
+
transport: {
|
|
242
|
+
rabbitmq: {
|
|
243
|
+
options: {
|
|
244
|
+
durable: true,
|
|
245
|
+
deadLetterExchange: 'matador.shared.dlx-undeliverable',
|
|
246
|
+
arguments: {
|
|
247
|
+
'x-queue-type': 'quorum',
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
})
|
|
253
|
+
.build();
|
|
254
|
+
expect(topology.queues[0]?.name).toBe('matador.shared.id-platform');
|
|
255
|
+
expect(topology.queues[0]?.exact).toBe(true);
|
|
256
|
+
expect(topology.queues[0]?.transport?.rabbitmq?.options?.durable).toBe(true);
|
|
257
|
+
expect(topology.queues[0]?.transport?.rabbitmq?.options?.deadLetterExchange).toBe('matador.shared.dlx-undeliverable');
|
|
258
|
+
expect(topology.queues[0]?.transport?.rabbitmq?.options?.arguments?.['x-queue-type']).toBe('quorum');
|
|
259
|
+
});
|
|
221
260
|
});
|
|
222
261
|
describe('addQueue with QueueDefinition object', () => {
|
|
223
262
|
it('should accept a QueueDefinition object', () => {
|
|
@@ -290,3 +329,32 @@ describe('TopologyBuilder', () => {
|
|
|
290
329
|
});
|
|
291
330
|
});
|
|
292
331
|
});
|
|
332
|
+
describe('resolveQueueName', () => {
|
|
333
|
+
it('should return namespace.name for regular queues', () => {
|
|
334
|
+
const queueDef = { name: 'events' };
|
|
335
|
+
expect(resolveQueueName('myapp', queueDef)).toBe('myapp.events');
|
|
336
|
+
});
|
|
337
|
+
it('should return name as-is when exact: true', () => {
|
|
338
|
+
const queueDef = { name: 'matador.shared.id-platform', exact: true };
|
|
339
|
+
expect(resolveQueueName('myapp', queueDef)).toBe('matador.shared.id-platform');
|
|
340
|
+
});
|
|
341
|
+
it('should return namespace.name when exact: false', () => {
|
|
342
|
+
const queueDef = { name: 'events', exact: false };
|
|
343
|
+
expect(resolveQueueName('myapp', queueDef)).toBe('myapp.events');
|
|
344
|
+
});
|
|
345
|
+
it('should work with full QueueDefinition including transport options', () => {
|
|
346
|
+
const queueDef = {
|
|
347
|
+
name: 'matador.shared.id-platform',
|
|
348
|
+
exact: true,
|
|
349
|
+
transport: {
|
|
350
|
+
rabbitmq: {
|
|
351
|
+
options: {
|
|
352
|
+
durable: true,
|
|
353
|
+
deadLetterExchange: 'matador.shared.dlx-undeliverable',
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
expect(resolveQueueName('myapp', queueDef)).toBe('matador.shared.id-platform');
|
|
359
|
+
});
|
|
360
|
+
});
|
package/dist/topology/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { DeadLetterConfig, DeadLetterQueueConfig, QueueDefinition, RetryConfig, Topology, } from './types.js';
|
|
2
|
-
export { getDeadLetterQueueName, getQualifiedQueueName, getRetryQueueName, } from './types.js';
|
|
1
|
+
export type { DeadLetterConfig, DeadLetterQueueConfig, QueueDefinition, RabbitMQQueueDefinition, RabbitMQQueueOptions, RetryConfig, Topology, TransportQueueOptions, } from './types.js';
|
|
2
|
+
export { getDeadLetterQueueName, getQualifiedQueueName, getRetryQueueName, resolveQueueName, } from './types.js';
|
|
3
3
|
export type { QueueOptions } from './builder.js';
|
|
4
4
|
export { TopologyBuilder, TopologyValidationError } from './builder.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/topology/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/topology/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/topology/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getDeadLetterQueueName, getQualifiedQueueName, getRetryQueueName, } from './types.js';
|
|
1
|
+
export { getDeadLetterQueueName, getQualifiedQueueName, getRetryQueueName, resolveQueueName, } from './types.js';
|
|
2
2
|
export { TopologyBuilder, TopologyValidationError } from './builder.js';
|
package/dist/topology/types.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface Topology {
|
|
|
16
16
|
* Individual queue definition.
|
|
17
17
|
*/
|
|
18
18
|
export interface QueueDefinition {
|
|
19
|
-
/** Queue name (will be prefixed with namespace) */
|
|
19
|
+
/** Queue name (will be prefixed with namespace unless exact: true) */
|
|
20
20
|
readonly name: string;
|
|
21
21
|
/** Concurrency for this queue */
|
|
22
22
|
readonly concurrency?: number | undefined;
|
|
@@ -31,6 +31,53 @@ export interface QueueDefinition {
|
|
|
31
31
|
* queues that are not managed by Matador.
|
|
32
32
|
*/
|
|
33
33
|
readonly exact?: boolean | undefined;
|
|
34
|
+
/** Transport-specific queue options */
|
|
35
|
+
readonly transport?: TransportQueueOptions | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Transport-specific queue options.
|
|
39
|
+
* Each transport can define its own options under its transport name key.
|
|
40
|
+
*/
|
|
41
|
+
export interface TransportQueueOptions {
|
|
42
|
+
/** RabbitMQ-specific queue options */
|
|
43
|
+
readonly rabbitmq?: RabbitMQQueueDefinition | undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* RabbitMQ-specific queue definition options.
|
|
47
|
+
*/
|
|
48
|
+
export interface RabbitMQQueueDefinition {
|
|
49
|
+
/**
|
|
50
|
+
* Exact RabbitMQ queue assertion options.
|
|
51
|
+
* When provided, these options completely replace all auto-computed defaults
|
|
52
|
+
* (durable, x-queue-type, x-dead-letter-exchange, etc.).
|
|
53
|
+
*/
|
|
54
|
+
readonly options?: RabbitMQQueueOptions | undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* RabbitMQ queue assertion options.
|
|
58
|
+
* Maps to amqplib's Options.AssertQueue.
|
|
59
|
+
*/
|
|
60
|
+
export interface RabbitMQQueueOptions {
|
|
61
|
+
/** Queue survives broker restart */
|
|
62
|
+
readonly durable?: boolean | undefined;
|
|
63
|
+
/** Queue is deleted when last consumer unsubscribes */
|
|
64
|
+
readonly autoDelete?: boolean | undefined;
|
|
65
|
+
/** Queue can only be used by the declaring connection */
|
|
66
|
+
readonly exclusive?: boolean | undefined;
|
|
67
|
+
/** Exchange to which dead-lettered messages are sent */
|
|
68
|
+
readonly deadLetterExchange?: string | undefined;
|
|
69
|
+
/** Routing key for dead-lettered messages */
|
|
70
|
+
readonly deadLetterRoutingKey?: string | undefined;
|
|
71
|
+
/** Message TTL in milliseconds */
|
|
72
|
+
readonly messageTtl?: number | undefined;
|
|
73
|
+
/** Queue expires after this many milliseconds of non-use */
|
|
74
|
+
readonly expires?: number | undefined;
|
|
75
|
+
/** Maximum number of messages in the queue */
|
|
76
|
+
readonly maxLength?: number | undefined;
|
|
77
|
+
/** Maximum priority level (0-255) */
|
|
78
|
+
readonly maxPriority?: number | undefined;
|
|
79
|
+
/** Additional x-* arguments for RabbitMQ */
|
|
80
|
+
readonly arguments?: Record<string, unknown> | undefined;
|
|
34
81
|
}
|
|
35
82
|
/**
|
|
36
83
|
* Dead-letter queue configuration.
|
|
@@ -73,4 +120,9 @@ export declare function getDeadLetterQueueName(namespace: string, queueName: str
|
|
|
73
120
|
* Gets the retry queue name for a given queue.
|
|
74
121
|
*/
|
|
75
122
|
export declare function getRetryQueueName(namespace: string, queueName: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Resolves the actual queue name for a given queue definition.
|
|
125
|
+
* When exact: true, returns name as-is. Otherwise, returns namespace.name.
|
|
126
|
+
*/
|
|
127
|
+
export declare function resolveQueueName(namespace: string, queueDef: QueueDefinition): string;
|
|
76
128
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/topology/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAE5C,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAEtC,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/topology/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAE5C,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAEtC,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW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;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,eAAe,GACxB,MAAM,CAKR"}
|
package/dist/topology/types.js
CHANGED
|
@@ -16,3 +16,13 @@ export function getDeadLetterQueueName(namespace, queueName, dlqType) {
|
|
|
16
16
|
export function getRetryQueueName(namespace, queueName) {
|
|
17
17
|
return `${namespace}.${queueName}.retry`;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the actual queue name for a given queue definition.
|
|
21
|
+
* When exact: true, returns name as-is. Otherwise, returns namespace.name.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveQueueName(namespace, queueDef) {
|
|
24
|
+
if (queueDef.exact) {
|
|
25
|
+
return queueDef.name;
|
|
26
|
+
}
|
|
27
|
+
return `${namespace}.${queueDef.name}`;
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rabbitmq-transport.d.ts","sourceRoot":"","sources":["../../../src/transport/rabbitmq/rabbitmq-transport.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,uCAAuC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC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MAAM,EACb,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,YAAY,CAAC;IAwFlB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAahD,gBAAgB,CACpB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IA6ChB;;;;;OAKG;YACW,uBAAuB;YAqCvB,SAAS;YAmCT,YAAY;YA+CZ,oBAAoB;YAwEpB,eAAe;YAgEf,gBAAgB;YAyBhB,sBAAsB;IA6BpC,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,gBAAgB;IAiBxB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CA0BzB"}
|
|
@@ -407,29 +407,37 @@ export class RabbitMQTransport {
|
|
|
407
407
|
const queueName = queueDef.exact
|
|
408
408
|
? queueDef.name
|
|
409
409
|
: `${topology.namespace}.${queueDef.name}`;
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
410
|
+
const rabbitmqOptions = queueDef.transport?.rabbitmq?.options;
|
|
411
|
+
// If user provided exact RabbitMQ options, use them directly (replaces all defaults)
|
|
412
|
+
if (rabbitmqOptions) {
|
|
413
|
+
await channel.assertQueue(queueName, rabbitmqOptions);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
// Use computed defaults
|
|
417
|
+
const queueOptions = {
|
|
418
|
+
durable: true,
|
|
419
|
+
arguments: {},
|
|
420
|
+
};
|
|
421
|
+
// Use quorum queues for durability
|
|
422
|
+
if (this.config.quorumQueues && !queueDef.exact) {
|
|
423
|
+
queueOptions.arguments['x-queue-type'] = 'quorum';
|
|
424
|
+
}
|
|
425
|
+
// Set up dead-letter exchange routing
|
|
426
|
+
const dlxExchange = this.getDLXExchangeName(topology.namespace);
|
|
427
|
+
if (topology.deadLetter.unhandled.enabled ||
|
|
428
|
+
topology.deadLetter.undeliverable.enabled) {
|
|
429
|
+
queueOptions.arguments['x-dead-letter-exchange'] = dlxExchange;
|
|
430
|
+
}
|
|
431
|
+
// Enable priority if requested
|
|
432
|
+
if (queueDef.priorities) {
|
|
433
|
+
queueOptions.arguments['x-max-priority'] = 10;
|
|
434
|
+
}
|
|
435
|
+
// Set consumer timeout if specified
|
|
436
|
+
if (queueDef.consumerTimeout) {
|
|
437
|
+
queueOptions.arguments['x-consumer-timeout'] = queueDef.consumerTimeout;
|
|
438
|
+
}
|
|
439
|
+
await channel.assertQueue(queueName, queueOptions);
|
|
431
440
|
}
|
|
432
|
-
await channel.assertQueue(queueName, queueOptions);
|
|
433
441
|
// Bind queue to main exchange
|
|
434
442
|
const mainExchange = this.getMainExchangeName(topology.namespace);
|
|
435
443
|
await channel.bindQueue(queueName, mainExchange, queueName);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it, mock } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { RabbitMQTransport, redactAmqpUrl } from './rabbitmq-transport.js';
|
|
3
3
|
describe('redactAmqpUrl', () => {
|
|
4
4
|
it('should redact username and password with 4 asterisks', () => {
|
|
5
5
|
const url = 'amqp://myuser:mypassword@localhost:5672';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SendResult } from '../core/fanout.js';
|
|
2
|
+
import type { Event, EventClass, EventOptions } from './event.js';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for dispatching events.
|
|
5
|
+
* Implemented by Matador to allow subscribers to send events.
|
|
6
|
+
*/
|
|
7
|
+
export interface Dispatcher {
|
|
8
|
+
/**
|
|
9
|
+
* Sends an event to all registered subscribers.
|
|
10
|
+
*/
|
|
11
|
+
send<T>(eventClass: EventClass<T>, data: T, options?: EventOptions): Promise<SendResult>;
|
|
12
|
+
send<T>(event: Event<T>, options?: EventOptions): Promise<SendResult>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/types/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,CAAC,CAAC,EACJ,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export type { DeliveryMode, Idempotency, Importance, ValidationError, ValidationResult, } from './common.js';
|
|
2
2
|
export { invalidResult, validResult } from './common.js';
|
|
3
|
+
export type { Dispatcher } from './dispatcher.js';
|
|
3
4
|
export type { CreateEnvelopeOptions, Docket, Envelope } from './envelope.js';
|
|
4
5
|
export { createEnvelope } from './envelope.js';
|
|
5
6
|
export type { Event, EventClass, EventData, EventKey, EventOptions, EventStatic, JsonPrimitive, JsonRecord, JsonValue, } from './event.js';
|
|
6
7
|
export { MatadorEvent } from './event.js';
|
|
7
|
-
export type { AnySubscriber, BaseSubscriberOptions, CreateResumableSubscriberInput, CreateStandardSubscriberInput, CreateSubscriberInput, EnvelopeOf, ResumableCallback, ResumableSubscriber, ResumableSubscriberOptions, StandardCallback, StandardSubscriber, StandardSubscriberOptions, Subscriber, SubscriberCallback, SubscriberDefinition, SubscriberOptions, SubscriberStub, } from './subscriber.js';
|
|
8
|
+
export type { AnySubscriber, BaseSubscriberOptions, CallbackContext, CreateResumableSubscriberInput, CreateStandardSubscriberInput, CreateSubscriberInput, EnvelopeOf, ResumableCallback, ResumableCallbackContext, ResumableSubscriber, ResumableSubscriberOptions, StandardCallback, StandardSubscriber, StandardSubscriberOptions, Subscriber, SubscriberCallback, SubscriberDefinition, SubscriberOptions, SubscriberStub, } from './subscriber.js';
|
|
8
9
|
export { createSubscriber, createSubscriberStub, isResumableSubscriber, isStandardSubscriber, isSubscriber, isSubscriberStub, } from './subscriber.js';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,YAAY,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAC7B,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,YAAY,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,8BAA8B,EAC9B,6BAA6B,EAC7B,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { SubscriberContext } from '../checkpoint/index.js';
|
|
2
2
|
import type { Idempotency, Importance } from './common.js';
|
|
3
|
+
import type { Dispatcher } from './dispatcher.js';
|
|
3
4
|
import type { Envelope } from './envelope.js';
|
|
4
5
|
import type { MatadorEvent } from './event.js';
|
|
6
|
+
/**
|
|
7
|
+
* Context passed to subscriber callbacks.
|
|
8
|
+
* Provides access to the Matador instance for sending additional events.
|
|
9
|
+
*/
|
|
10
|
+
export interface CallbackContext {
|
|
11
|
+
/** Matador dispatcher for sending additional events from within a subscriber */
|
|
12
|
+
readonly matador: Dispatcher;
|
|
13
|
+
}
|
|
5
14
|
/**
|
|
6
15
|
* Helper type to get the envelope type for a subscriber callback.
|
|
7
16
|
* Extracts the data type from a MatadorEvent and wraps it in an Envelope.
|
|
@@ -14,14 +23,21 @@ import type { MatadorEvent } from './event.js';
|
|
|
14
23
|
export type EnvelopeOf<T extends MatadorEvent> = Envelope<T['data']>;
|
|
15
24
|
/**
|
|
16
25
|
* Callback function executed when an event is received (standard subscribers).
|
|
17
|
-
* Receives the full envelope containing id, data, and docket
|
|
26
|
+
* Receives the full envelope containing id, data, and docket, plus a context
|
|
27
|
+
* with access to the matador instance for sending additional events.
|
|
28
|
+
*/
|
|
29
|
+
export type StandardCallback<T = unknown> = (envelope: Envelope<T>, context: CallbackContext) => Promise<void> | void;
|
|
30
|
+
/**
|
|
31
|
+
* Context for resumable subscriber callbacks.
|
|
32
|
+
* Combines checkpoint operations (io, all) with matador access.
|
|
18
33
|
*/
|
|
19
|
-
export type
|
|
34
|
+
export type ResumableCallbackContext = SubscriberContext & CallbackContext;
|
|
20
35
|
/**
|
|
21
36
|
* Callback function for resumable subscribers.
|
|
22
|
-
* Receives the envelope and a
|
|
37
|
+
* Receives the envelope and a context with io() for checkpointed operations
|
|
38
|
+
* and matador for sending additional events.
|
|
23
39
|
*/
|
|
24
|
-
export type ResumableCallback<T = unknown> = (envelope: Envelope<T>, context:
|
|
40
|
+
export type ResumableCallback<T = unknown> = (envelope: Envelope<T>, context: ResumableCallbackContext) => Promise<void> | void;
|
|
25
41
|
/**
|
|
26
42
|
* Callback function executed when an event is received.
|
|
27
43
|
* @deprecated Use StandardCallback or ResumableCallback instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriber.d.ts","sourceRoot":"","sources":["../../src/types/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,YAAY,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAErE
|
|
1
|
+
{"version":3,"file":"subscriber.d.ts","sourceRoot":"","sources":["../../src/types/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;G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E,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C"}
|
package/package.json
CHANGED
package/src/core/matador.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { getQualifiedQueueName } from '../topology/index.js';
|
|
|
18
18
|
import type { Subscription, Transport } from '../transport/index.js';
|
|
19
19
|
import type {
|
|
20
20
|
AnySubscriber,
|
|
21
|
+
Dispatcher,
|
|
21
22
|
Event,
|
|
22
23
|
EventClass,
|
|
23
24
|
EventOptions,
|
|
@@ -71,7 +72,7 @@ export interface MatadorConfig {
|
|
|
71
72
|
* - Fanout: Event sending
|
|
72
73
|
* - Shutdown: Graceful termination
|
|
73
74
|
*/
|
|
74
|
-
export class Matador {
|
|
75
|
+
export class Matador implements Dispatcher {
|
|
75
76
|
private readonly transport: Transport;
|
|
76
77
|
private readonly topology: Topology;
|
|
77
78
|
private readonly schema;
|
|
@@ -114,6 +115,7 @@ export class Matador {
|
|
|
114
115
|
retryPolicy: this.retryPolicy,
|
|
115
116
|
hooks: this.hooks,
|
|
116
117
|
checkpointStore: config.checkpointStore,
|
|
118
|
+
dispatcher: this,
|
|
117
119
|
});
|
|
118
120
|
|
|
119
121
|
// Create fanout engine
|
package/src/index.ts
CHANGED
|
@@ -19,8 +19,10 @@ export {
|
|
|
19
19
|
export type {
|
|
20
20
|
AnySubscriber,
|
|
21
21
|
BaseSubscriberOptions,
|
|
22
|
+
CallbackContext,
|
|
22
23
|
CreateEnvelopeOptions,
|
|
23
24
|
DeliveryMode,
|
|
25
|
+
Dispatcher,
|
|
24
26
|
Docket,
|
|
25
27
|
Envelope,
|
|
26
28
|
EnvelopeOf,
|
|
@@ -33,6 +35,9 @@ export type {
|
|
|
33
35
|
Idempotency,
|
|
34
36
|
Importance,
|
|
35
37
|
JsonRecord,
|
|
38
|
+
ResumableCallback,
|
|
39
|
+
ResumableCallbackContext,
|
|
40
|
+
StandardCallback,
|
|
36
41
|
Subscriber,
|
|
37
42
|
SubscriberCallback,
|
|
38
43
|
SubscriberDefinition,
|
|
@@ -91,13 +96,17 @@ export type {
|
|
|
91
96
|
DeadLetterQueueConfig,
|
|
92
97
|
QueueDefinition,
|
|
93
98
|
QueueOptions,
|
|
99
|
+
RabbitMQQueueDefinition,
|
|
100
|
+
RabbitMQQueueOptions,
|
|
94
101
|
RetryConfig,
|
|
95
102
|
Topology,
|
|
103
|
+
TransportQueueOptions,
|
|
96
104
|
} from './topology/index.js';
|
|
97
105
|
export {
|
|
98
106
|
getDeadLetterQueueName,
|
|
99
107
|
getQualifiedQueueName,
|
|
100
108
|
getRetryQueueName,
|
|
109
|
+
resolveQueueName,
|
|
101
110
|
TopologyBuilder,
|
|
102
111
|
TopologyValidationError,
|
|
103
112
|
} from './topology/index.js';
|