@zdavison/matador 3.0.6 → 4.0.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/core/fanout.d.ts +3 -2
- package/dist/core/fanout.d.ts.map +1 -1
- package/dist/core/fanout.js +4 -4
- package/dist/core/fanout.test.js +32 -24
- package/dist/core/matador.d.ts.map +1 -1
- package/dist/core/matador.js +16 -7
- package/dist/core/matador.test.js +32 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/matador-errors.d.ts +28 -0
- package/dist/errors/matador-errors.d.ts.map +1 -1
- package/dist/errors/matador-errors.js +41 -0
- package/dist/index.cjs +325 -80
- 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 +3 -3
- package/dist/index.js.map +1 -1
- package/dist/topology/builder.d.ts +26 -1
- package/dist/topology/builder.d.ts.map +1 -1
- package/dist/topology/builder.js +72 -0
- package/dist/topology/builder.test.js +179 -1
- 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 +108 -6
- package/dist/topology/types.d.ts.map +1 -1
- package/dist/topology/types.js +50 -10
- package/dist/transport/local/local-transport.d.ts.map +1 -1
- package/dist/transport/local/local-transport.js +5 -2
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.d.ts +2 -0
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.d.ts.map +1 -0
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.js +110 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts +24 -0
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -1
- package/dist/transport/rabbitmq/rabbitmq-transport.js +145 -68
- package/dist/transport/rabbitmq/rabbitmq-transport.test.js +130 -0
- package/package.json +6 -2
package/dist/core/fanout.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SafeHooks } from '../hooks/index.js';
|
|
2
2
|
import type { SchemaRegistry } from '../schema/index.js';
|
|
3
|
+
import type { Topology } from '../topology/index.js';
|
|
3
4
|
import type { Transport } from '../transport/index.js';
|
|
4
5
|
import type { Event, EventClass, EventOptions } from '../types/index.js';
|
|
5
6
|
/**
|
|
@@ -9,7 +10,7 @@ export interface FanoutConfig {
|
|
|
9
10
|
readonly transport: Transport;
|
|
10
11
|
readonly schema: SchemaRegistry;
|
|
11
12
|
readonly hooks: SafeHooks;
|
|
12
|
-
readonly
|
|
13
|
+
readonly topology: Topology;
|
|
13
14
|
readonly defaultQueue: string;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
@@ -42,7 +43,7 @@ export declare class FanoutEngine {
|
|
|
42
43
|
private readonly transport;
|
|
43
44
|
private readonly schema;
|
|
44
45
|
private readonly hooks;
|
|
45
|
-
private readonly
|
|
46
|
+
private readonly topology;
|
|
46
47
|
private readonly defaultQueue;
|
|
47
48
|
private enqueuingCount;
|
|
48
49
|
constructor(config: FanoutConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fanout.d.ts","sourceRoot":"","sources":["../../src/core/fanout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"fanout.d.ts","sourceRoot":"","sources":["../../src/core/fanout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EA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K,CAAC,CAAC,CAAC,EACf,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,UAAU,CAAC;YAsFR,mBAAmB;CAelC"}
|
package/dist/core/fanout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransportSendError } from '../errors/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveTargetQueueName } from '../topology/index.js';
|
|
3
3
|
import { createEnvelope } from '../types/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Engine for fanning out events to subscribers.
|
|
@@ -14,14 +14,14 @@ export class FanoutEngine {
|
|
|
14
14
|
transport;
|
|
15
15
|
schema;
|
|
16
16
|
hooks;
|
|
17
|
-
|
|
17
|
+
topology;
|
|
18
18
|
defaultQueue;
|
|
19
19
|
enqueuingCount = 0;
|
|
20
20
|
constructor(config) {
|
|
21
21
|
this.transport = config.transport;
|
|
22
22
|
this.schema = config.schema;
|
|
23
23
|
this.hooks = config.hooks;
|
|
24
|
-
this.
|
|
24
|
+
this.topology = config.topology;
|
|
25
25
|
this.defaultQueue = config.defaultQueue;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -54,7 +54,7 @@ export class FanoutEngine {
|
|
|
54
54
|
}
|
|
55
55
|
// Determine target queue
|
|
56
56
|
const targetQueue = subscriber.targetQueue ?? this.defaultQueue;
|
|
57
|
-
const qualifiedQueue =
|
|
57
|
+
const qualifiedQueue = resolveTargetQueueName(this.topology, targetQueue);
|
|
58
58
|
// Create envelope
|
|
59
59
|
const envelope = createEnvelope({
|
|
60
60
|
eventKey,
|
package/dist/core/fanout.test.js
CHANGED
|
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
|
2
2
|
import { TransportSendError } from '../errors/index.js';
|
|
3
3
|
import { SafeHooks } from '../hooks/index.js';
|
|
4
4
|
import { SchemaRegistry } from '../schema/index.js';
|
|
5
|
+
import { TopologyBuilder } from '../topology/index.js';
|
|
5
6
|
import { MatadorEvent, createSubscriber, createSubscriberStub, } from '../types/index.js';
|
|
6
7
|
import { FanoutEngine } from './fanout.js';
|
|
7
8
|
class UserCreatedEvent extends MatadorEvent {
|
|
@@ -33,6 +34,13 @@ class UserCreatedEventWithMetadata extends MatadorEvent {
|
|
|
33
34
|
this.metadata = metadata;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
const testTopology = TopologyBuilder.create()
|
|
38
|
+
.withNamespace('test')
|
|
39
|
+
.addQueue('events')
|
|
40
|
+
.addQueue('notifications')
|
|
41
|
+
.addQueue('queue-1')
|
|
42
|
+
.addQueue('queue-2')
|
|
43
|
+
.build();
|
|
36
44
|
describe('FanoutEngine', () => {
|
|
37
45
|
let transport;
|
|
38
46
|
let schema;
|
|
@@ -67,7 +75,7 @@ describe('FanoutEngine', () => {
|
|
|
67
75
|
transport,
|
|
68
76
|
schema,
|
|
69
77
|
hooks,
|
|
70
|
-
|
|
78
|
+
topology: testTopology,
|
|
71
79
|
defaultQueue: 'events',
|
|
72
80
|
});
|
|
73
81
|
});
|
|
@@ -80,7 +88,7 @@ describe('FanoutEngine', () => {
|
|
|
80
88
|
transport,
|
|
81
89
|
schema,
|
|
82
90
|
hooks,
|
|
83
|
-
|
|
91
|
+
topology: testTopology,
|
|
84
92
|
defaultQueue: 'events',
|
|
85
93
|
});
|
|
86
94
|
expect(instance).toBeInstanceOf(FanoutEngine);
|
|
@@ -120,7 +128,7 @@ describe('FanoutEngine', () => {
|
|
|
120
128
|
email: 'test@example.com',
|
|
121
129
|
});
|
|
122
130
|
await fanout.send(UserCreatedEvent, event);
|
|
123
|
-
expect(transport.send).toHaveBeenCalledWith('test.events', expect.any(Object), undefined);
|
|
131
|
+
expect(transport.send).toHaveBeenCalledWith('matador.test.events', expect.any(Object), undefined);
|
|
124
132
|
});
|
|
125
133
|
it('should use subscriber targetQueue when specified', async () => {
|
|
126
134
|
const subscriber = createSubscriber({
|
|
@@ -135,7 +143,7 @@ describe('FanoutEngine', () => {
|
|
|
135
143
|
email: 'test@example.com',
|
|
136
144
|
});
|
|
137
145
|
await fanout.send(UserCreatedEvent, event);
|
|
138
|
-
expect(transport.send).toHaveBeenCalledWith('test.notifications', expect.any(Object), undefined);
|
|
146
|
+
expect(transport.send).toHaveBeenCalledWith('matador.test.notifications', expect.any(Object), undefined);
|
|
139
147
|
});
|
|
140
148
|
it('should create envelope with correct structure', async () => {
|
|
141
149
|
const subscriber = createSubscriber({
|
|
@@ -258,8 +266,8 @@ describe('FanoutEngine', () => {
|
|
|
258
266
|
});
|
|
259
267
|
await fanout.send(UserCreatedEvent, event);
|
|
260
268
|
const calls = transport.send.mock.calls;
|
|
261
|
-
expect(calls[0]?.[0]).toBe('test.queue-1');
|
|
262
|
-
expect(calls[1]?.[0]).toBe('test.queue-2');
|
|
269
|
+
expect(calls[0]?.[0]).toBe('matador.test.queue-1');
|
|
270
|
+
expect(calls[1]?.[0]).toBe('matador.test.queue-2');
|
|
263
271
|
});
|
|
264
272
|
it('should send to no subscribers when event is not registered', async () => {
|
|
265
273
|
const event = new OrderPlacedEvent({
|
|
@@ -338,7 +346,7 @@ describe('FanoutEngine', () => {
|
|
|
338
346
|
transport,
|
|
339
347
|
schema,
|
|
340
348
|
hooks: hooksInstance,
|
|
341
|
-
|
|
349
|
+
topology: testTopology,
|
|
342
350
|
defaultQueue: 'events',
|
|
343
351
|
});
|
|
344
352
|
const subscriber = createSubscriber({
|
|
@@ -518,7 +526,7 @@ describe('FanoutEngine', () => {
|
|
|
518
526
|
transport: failingTransport,
|
|
519
527
|
schema,
|
|
520
528
|
hooks,
|
|
521
|
-
|
|
529
|
+
topology: testTopology,
|
|
522
530
|
defaultQueue: 'events',
|
|
523
531
|
});
|
|
524
532
|
const subscriber = createSubscriber({
|
|
@@ -536,14 +544,14 @@ describe('FanoutEngine', () => {
|
|
|
536
544
|
expect(result.subscribersSkipped).toBe(0);
|
|
537
545
|
expect(result.errors).toHaveLength(1);
|
|
538
546
|
expect(result.errors[0]?.subscriberName).toBe('handle-user');
|
|
539
|
-
expect(result.errors[0]?.queue).toBe('test.events');
|
|
547
|
+
expect(result.errors[0]?.queue).toBe('matador.test.events');
|
|
540
548
|
expect(result.errors[0]?.error).toBeInstanceOf(TransportSendError);
|
|
541
549
|
});
|
|
542
550
|
it('should continue sending to other subscribers after one fails', async () => {
|
|
543
551
|
const failingTransport = {
|
|
544
552
|
...transport,
|
|
545
553
|
send: mock(async (queue) => {
|
|
546
|
-
if (queue === 'test.queue-1') {
|
|
554
|
+
if (queue === 'matador.test.queue-1') {
|
|
547
555
|
throw new Error('Queue 1 failed');
|
|
548
556
|
}
|
|
549
557
|
return 'mock';
|
|
@@ -553,7 +561,7 @@ describe('FanoutEngine', () => {
|
|
|
553
561
|
transport: failingTransport,
|
|
554
562
|
schema,
|
|
555
563
|
hooks,
|
|
556
|
-
|
|
564
|
+
topology: testTopology,
|
|
557
565
|
defaultQueue: 'events',
|
|
558
566
|
});
|
|
559
567
|
const sub1 = createSubscriber({
|
|
@@ -590,7 +598,7 @@ describe('FanoutEngine', () => {
|
|
|
590
598
|
transport: failingTransport,
|
|
591
599
|
schema,
|
|
592
600
|
hooks,
|
|
593
|
-
|
|
601
|
+
topology: testTopology,
|
|
594
602
|
defaultQueue: 'events',
|
|
595
603
|
});
|
|
596
604
|
const subscriber = createSubscriber({
|
|
@@ -606,7 +614,7 @@ describe('FanoutEngine', () => {
|
|
|
606
614
|
const result = await fanoutWithFailingTransport.send(UserCreatedEvent, event);
|
|
607
615
|
expect(result.errors).toHaveLength(1);
|
|
608
616
|
expect(result.errors[0]?.error).toBeInstanceOf(TransportSendError);
|
|
609
|
-
expect(result.errors[0]?.error.message).toContain('test.events');
|
|
617
|
+
expect(result.errors[0]?.error.message).toContain('matador.test.events');
|
|
610
618
|
});
|
|
611
619
|
});
|
|
612
620
|
describe('eventsBeingEnqueuedCount tracking', () => {
|
|
@@ -625,7 +633,7 @@ describe('FanoutEngine', () => {
|
|
|
625
633
|
transport: trackingTransport,
|
|
626
634
|
schema,
|
|
627
635
|
hooks,
|
|
628
|
-
|
|
636
|
+
topology: testTopology,
|
|
629
637
|
defaultQueue: 'events',
|
|
630
638
|
});
|
|
631
639
|
const subscriber = createSubscriber({
|
|
@@ -668,7 +676,7 @@ describe('FanoutEngine', () => {
|
|
|
668
676
|
transport: failingTransport,
|
|
669
677
|
schema,
|
|
670
678
|
hooks,
|
|
671
|
-
|
|
679
|
+
topology: testTopology,
|
|
672
680
|
defaultQueue: 'events',
|
|
673
681
|
});
|
|
674
682
|
const subscriber = createSubscriber({
|
|
@@ -715,7 +723,7 @@ describe('FanoutEngine', () => {
|
|
|
715
723
|
transport: trackingTransport,
|
|
716
724
|
schema,
|
|
717
725
|
hooks,
|
|
718
|
-
|
|
726
|
+
topology: testTopology,
|
|
719
727
|
defaultQueue: 'events',
|
|
720
728
|
});
|
|
721
729
|
const event = new UserCreatedEvent({
|
|
@@ -802,7 +810,7 @@ describe('FanoutEngine', () => {
|
|
|
802
810
|
transport,
|
|
803
811
|
schema,
|
|
804
812
|
hooks: hooksInstance,
|
|
805
|
-
|
|
813
|
+
topology: testTopology,
|
|
806
814
|
defaultQueue: 'events',
|
|
807
815
|
});
|
|
808
816
|
const subscriber = createSubscriber({
|
|
@@ -819,7 +827,7 @@ describe('FanoutEngine', () => {
|
|
|
819
827
|
expect(onEnqueueSuccess).toHaveBeenCalledTimes(1);
|
|
820
828
|
expect(onEnqueueSuccess).toHaveBeenCalledWith({
|
|
821
829
|
envelope: expect.any(Object),
|
|
822
|
-
queue: 'test.events',
|
|
830
|
+
queue: 'matador.test.events',
|
|
823
831
|
transport: 'mock',
|
|
824
832
|
});
|
|
825
833
|
const calls = onEnqueueSuccess.mock.calls;
|
|
@@ -846,7 +854,7 @@ describe('FanoutEngine', () => {
|
|
|
846
854
|
transport: failingTransport,
|
|
847
855
|
schema,
|
|
848
856
|
hooks: hooksInstance,
|
|
849
|
-
|
|
857
|
+
topology: testTopology,
|
|
850
858
|
defaultQueue: 'events',
|
|
851
859
|
});
|
|
852
860
|
const subscriber = createSubscriber({
|
|
@@ -884,7 +892,7 @@ describe('FanoutEngine', () => {
|
|
|
884
892
|
transport,
|
|
885
893
|
schema,
|
|
886
894
|
hooks: hooksInstance,
|
|
887
|
-
|
|
895
|
+
topology: testTopology,
|
|
888
896
|
defaultQueue: 'events',
|
|
889
897
|
});
|
|
890
898
|
const sub1 = createSubscriber({
|
|
@@ -920,7 +928,7 @@ describe('FanoutEngine', () => {
|
|
|
920
928
|
transport,
|
|
921
929
|
schema,
|
|
922
930
|
hooks: hooksInstance,
|
|
923
|
-
|
|
931
|
+
topology: testTopology,
|
|
924
932
|
defaultQueue: 'events',
|
|
925
933
|
});
|
|
926
934
|
const subscriber = createSubscriber({
|
|
@@ -949,7 +957,7 @@ describe('FanoutEngine', () => {
|
|
|
949
957
|
transport,
|
|
950
958
|
schema,
|
|
951
959
|
hooks: hooksInstance,
|
|
952
|
-
|
|
960
|
+
topology: testTopology,
|
|
953
961
|
defaultQueue: 'events',
|
|
954
962
|
});
|
|
955
963
|
const subscriber = createSubscriber({
|
|
@@ -984,7 +992,7 @@ describe('FanoutEngine', () => {
|
|
|
984
992
|
delayMs: 5000,
|
|
985
993
|
};
|
|
986
994
|
await fanout.send(UserCreatedEvent, event, options);
|
|
987
|
-
expect(transport.send).toHaveBeenCalledWith('test.events', expect.any(Object), { delay: 5000 });
|
|
995
|
+
expect(transport.send).toHaveBeenCalledWith('matador.test.events', expect.any(Object), { delay: 5000 });
|
|
988
996
|
});
|
|
989
997
|
it('should include delay in envelope', async () => {
|
|
990
998
|
const subscriber = createSubscriber({
|
|
@@ -1023,7 +1031,7 @@ describe('FanoutEngine', () => {
|
|
|
1023
1031
|
email: 'test@example.com',
|
|
1024
1032
|
});
|
|
1025
1033
|
await fanout.send(UserCreatedEvent, event);
|
|
1026
|
-
expect(transport.send).toHaveBeenCalledWith('test.events', expect.any(Object), undefined);
|
|
1034
|
+
expect(transport.send).toHaveBeenCalledWith('matador.test.events', expect.any(Object), undefined);
|
|
1027
1035
|
});
|
|
1028
1036
|
});
|
|
1029
1037
|
describe('subscriber importance', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matador.d.ts","sourceRoot":"","sources":["../../src/core/matador.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"matador.d.ts","sourceRoot":"","sources":["../../src/core/matador.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAQ/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,KAAK,EACL,UAAU,EACV,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGnE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,6BAA6B;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,sDAAsD;IACtD,QAA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,GAAG,IAAI;IAc3C;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiE5B;;;;;;;;;;;;OAYG;IACG,IAAI,CAAC,CAAC,EACV,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC;IAChB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IAuC3E;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACG,WAAW,CAAC,SAAS,SAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAatD;;;;;;;;;;;OAWG;IACG,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAQvC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;OAEG;IACH,WAAW,IAAI,OAAO;YAIR,cAAc;CAM7B"}
|
package/dist/core/matador.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { JsonCodec } from '../codec/index.js';
|
|
2
|
-
import { InvalidSchemaError, NotStartedError, ShutdownInProgressError, } from '../errors/index.js';
|
|
2
|
+
import { InvalidSchemaError, NotStartedError, ShutdownInProgressError, SomeSendError, } from '../errors/index.js';
|
|
3
3
|
import { SafeHooks } from '../hooks/index.js';
|
|
4
4
|
import { ProcessingPipeline } from '../pipeline/index.js';
|
|
5
5
|
import { StandardRetryPolicy } from '../retry/index.js';
|
|
6
6
|
import { SchemaRegistry, isSchemaEntryTuple } from '../schema/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import { findQueueDefinition, resolveTargetQueueName, } from '../topology/index.js';
|
|
8
8
|
import { FanoutEngine } from './fanout.js';
|
|
9
9
|
import { ShutdownManager } from './shutdown.js';
|
|
10
10
|
/**
|
|
@@ -64,7 +64,7 @@ export class Matador {
|
|
|
64
64
|
transport: this.transport,
|
|
65
65
|
schema: this.schema,
|
|
66
66
|
hooks: this.hooks,
|
|
67
|
-
|
|
67
|
+
topology: this.topology,
|
|
68
68
|
defaultQueue,
|
|
69
69
|
});
|
|
70
70
|
// Create shutdown manager
|
|
@@ -134,9 +134,12 @@ export class Matador {
|
|
|
134
134
|
if (this.consumeFrom.length > 0) {
|
|
135
135
|
this.hooks.logger.info(`[Matador] 🟢 Worker subscribing to '${this.consumeFrom.join(',')}'.`);
|
|
136
136
|
}
|
|
137
|
+
else {
|
|
138
|
+
this.hooks.logger.info('[Matador] 🟡 Worker not subscribing to any queues (consumeFrom is empty).');
|
|
139
|
+
}
|
|
137
140
|
for (const queueName of this.consumeFrom) {
|
|
138
|
-
const qualifiedName =
|
|
139
|
-
const queueDef = this.topology
|
|
141
|
+
const qualifiedName = resolveTargetQueueName(this.topology, queueName);
|
|
142
|
+
const queueDef = findQueueDefinition(this.topology, queueName);
|
|
140
143
|
const subscription = await this.transport.subscribe(qualifiedName, async (envelope, receipt) => {
|
|
141
144
|
this.shutdownManager.incrementProcessing();
|
|
142
145
|
try {
|
|
@@ -168,13 +171,19 @@ export class Matador {
|
|
|
168
171
|
const data = dataOrOptions;
|
|
169
172
|
const options = maybeOptions;
|
|
170
173
|
const event = new eventClass(data);
|
|
171
|
-
|
|
174
|
+
const result = await this.fanout.send(eventClass, event, options);
|
|
175
|
+
if (result.errors.length > 0)
|
|
176
|
+
throw new SomeSendError(result.eventKey, result.errors);
|
|
177
|
+
return result;
|
|
172
178
|
}
|
|
173
179
|
// Called as: send(event, options?)
|
|
174
180
|
const event = eventOrClass;
|
|
175
181
|
const options = dataOrOptions;
|
|
176
182
|
const eventClass = event.constructor;
|
|
177
|
-
|
|
183
|
+
const result = await this.fanout.send(eventClass, event, options);
|
|
184
|
+
if (result.errors.length > 0)
|
|
185
|
+
throw new SomeSendError(result.eventKey, result.errors);
|
|
186
|
+
return result;
|
|
178
187
|
}
|
|
179
188
|
/**
|
|
180
189
|
* Gets current handler state.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
2
|
+
import { SomeSendError, TransportSendError } from '../errors/index.js';
|
|
2
3
|
import { TopologyBuilder } from '../topology/builder.js';
|
|
3
4
|
import { LocalTransport } from '../transport/local/local-transport.js';
|
|
4
5
|
import { MatadorEvent, createSubscriber } from '../types/index.js';
|
|
@@ -296,6 +297,36 @@ describe('Matador', () => {
|
|
|
296
297
|
});
|
|
297
298
|
expect(result.subscribersSent).toBe(1);
|
|
298
299
|
});
|
|
300
|
+
it('should throw SomeSendError when transport send fails', async () => {
|
|
301
|
+
const topology = TopologyBuilder.create()
|
|
302
|
+
.withNamespace('test')
|
|
303
|
+
.addQueue('events')
|
|
304
|
+
.build();
|
|
305
|
+
const subscriber = createSubscriber({
|
|
306
|
+
name: 'handle-user',
|
|
307
|
+
description: 'Handles user events',
|
|
308
|
+
callback: async () => { },
|
|
309
|
+
});
|
|
310
|
+
const schema = {
|
|
311
|
+
[UserCreatedEvent.key]: [UserCreatedEvent, [subscriber]],
|
|
312
|
+
};
|
|
313
|
+
matador = new Matador({ transport, topology, schema });
|
|
314
|
+
await matador.start();
|
|
315
|
+
const sendError = new Error('Network timeout');
|
|
316
|
+
transport.send = mock(async () => {
|
|
317
|
+
throw sendError;
|
|
318
|
+
});
|
|
319
|
+
const thrown = await matador
|
|
320
|
+
.send(new UserCreatedEvent({ userId: '123', email: 'test@example.com' }))
|
|
321
|
+
.catch((e) => e);
|
|
322
|
+
expect(thrown).toBeInstanceOf(SomeSendError);
|
|
323
|
+
expect(thrown.eventKey).toBe(UserCreatedEvent.key);
|
|
324
|
+
expect(thrown.errors).toHaveLength(1);
|
|
325
|
+
expect(thrown.errors[0]?.subscriberName).toBe('handle-user');
|
|
326
|
+
expect(thrown.errors[0]?.queue).toBe('matador.test.events');
|
|
327
|
+
expect(thrown.errors[0]?.error).toBeInstanceOf(TransportSendError);
|
|
328
|
+
expect(thrown.errors[0]?.error.cause).toBe(sendError);
|
|
329
|
+
});
|
|
299
330
|
});
|
|
300
331
|
describe('shutdown', () => {
|
|
301
332
|
it('should gracefully shutdown', async () => {
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { HasDescription } from './has-description.js';
|
|
2
2
|
export { hasDescription } from './has-description.js';
|
|
3
3
|
export { assertEvent, DontRetry, DoRetry, EventAssertionError, isAssertionError, isDontRetry, isDoRetry, RetryControlError, } from './retry-errors.js';
|
|
4
|
-
export { MatadorError, isMatadorError, NotStartedError, isNotStartedError, ShutdownInProgressError, TransportNotConnectedError, isTransportNotConnectedError, TransportClosedError, TransportSendError, AllTransportsFailedError, DelayedMessagesNotSupportedError, EventNotRegisteredError, isEventNotRegisteredError, SubscriberNotRegisteredError, isSubscriberNotRegisteredError, NoSubscribersExistError, InvalidSchemaError, SubscriberIsStubError, LocalTransportCannotProcessStubError, QueueNotFoundError, InvalidEventError, MessageMaybePoisonedError, isMessageMaybePoisonedError, IdempotentMessageCannotRetryError, isIdempotentMessageCannotRetryError, TimeoutError, } from './matador-errors.js';
|
|
4
|
+
export { MatadorError, isMatadorError, NotStartedError, isNotStartedError, ShutdownInProgressError, TransportNotConnectedError, isTransportNotConnectedError, TransportClosedError, TransportSendError, SomeSendError, AllTransportsFailedError, DelayedMessagesNotSupportedError, EventNotRegisteredError, isEventNotRegisteredError, SubscriberNotRegisteredError, isSubscriberNotRegisteredError, NoSubscribersExistError, InvalidSchemaError, SubscriberIsStubError, LocalTransportCannotProcessStubError, QueueNotFoundError, UnknownQueueReferenceError, isUnknownQueueReferenceError, InvalidEventError, MessageMaybePoisonedError, isMessageMaybePoisonedError, IdempotentMessageCannotRetryError, isIdempotentMessageCannotRetryError, TimeoutError, } from './matador-errors.js';
|
|
5
5
|
export { CheckpointStoreError, DuplicateIoKeyError, isCheckpointStoreError, isDuplicateIoKeyError, } from './checkpoint-errors.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,YAAY,EACZ,cAAc,EAEd,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EAEvB,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,gCAAgC,EAEhC,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,oCAAoC,EAEpC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,YAAY,EACZ,cAAc,EAEd,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EAEvB,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,gCAAgC,EAEhC,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,oCAAoC,EAEpC,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,EAE5B,iBAAiB,EAEjB,yBAAyB,EACzB,2BAA2B,EAC3B,iCAAiC,EACjC,mCAAmC,EAEnC,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC"}
|
package/dist/errors/index.js
CHANGED
|
@@ -6,11 +6,11 @@ MatadorError, isMatadorError,
|
|
|
6
6
|
// Lifecycle errors
|
|
7
7
|
NotStartedError, isNotStartedError, ShutdownInProgressError,
|
|
8
8
|
// Transport errors
|
|
9
|
-
TransportNotConnectedError, isTransportNotConnectedError, TransportClosedError, TransportSendError, AllTransportsFailedError, DelayedMessagesNotSupportedError,
|
|
9
|
+
TransportNotConnectedError, isTransportNotConnectedError, TransportClosedError, TransportSendError, SomeSendError, AllTransportsFailedError, DelayedMessagesNotSupportedError,
|
|
10
10
|
// Schema & configuration errors
|
|
11
11
|
EventNotRegisteredError, isEventNotRegisteredError, SubscriberNotRegisteredError, isSubscriberNotRegisteredError, NoSubscribersExistError, InvalidSchemaError, SubscriberIsStubError, LocalTransportCannotProcessStubError,
|
|
12
12
|
// Queue errors
|
|
13
|
-
QueueNotFoundError,
|
|
13
|
+
QueueNotFoundError, UnknownQueueReferenceError, isUnknownQueueReferenceError,
|
|
14
14
|
// Event validation errors
|
|
15
15
|
InvalidEventError,
|
|
16
16
|
// Message processing errors
|
|
@@ -72,6 +72,24 @@ export declare class TransportSendError extends MatadorError {
|
|
|
72
72
|
constructor(queue: string, cause: Error);
|
|
73
73
|
toJSON(): Record<string, unknown>;
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Thrown when send() completes but one or more subscriber publishes failed.
|
|
77
|
+
* The `errors` array contains per-failure details: subscriber name, target queue, and underlying error.
|
|
78
|
+
*/
|
|
79
|
+
export declare class SomeSendError extends MatadorError {
|
|
80
|
+
readonly eventKey: string;
|
|
81
|
+
readonly errors: ReadonlyArray<{
|
|
82
|
+
subscriberName: string;
|
|
83
|
+
queue: string;
|
|
84
|
+
error: Error;
|
|
85
|
+
}>;
|
|
86
|
+
readonly description: string;
|
|
87
|
+
constructor(eventKey: string, errors: ReadonlyArray<{
|
|
88
|
+
subscriberName: string;
|
|
89
|
+
queue: string;
|
|
90
|
+
error: Error;
|
|
91
|
+
}>);
|
|
92
|
+
}
|
|
75
93
|
/**
|
|
76
94
|
* Thrown when delayed messages are requested but the plugin is not available.
|
|
77
95
|
*/
|
|
@@ -129,6 +147,15 @@ export declare class LocalTransportCannotProcessStubError extends MatadorError {
|
|
|
129
147
|
readonly description: string;
|
|
130
148
|
constructor(subscriberName: string);
|
|
131
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Thrown when a subscriber's `targetQueue` or a `consumeFrom` entry references
|
|
152
|
+
* a queue that was never declared in the topology.
|
|
153
|
+
*/
|
|
154
|
+
export declare class UnknownQueueReferenceError extends MatadorError {
|
|
155
|
+
readonly queueName: string;
|
|
156
|
+
readonly description: string;
|
|
157
|
+
constructor(queueName: string);
|
|
158
|
+
}
|
|
132
159
|
/**
|
|
133
160
|
* Thrown when a queue is not found or not created.
|
|
134
161
|
*/
|
|
@@ -178,6 +205,7 @@ export declare function isNotStartedError(error: unknown): error is NotStartedEr
|
|
|
178
205
|
export declare function isTransportNotConnectedError(error: unknown): error is TransportNotConnectedError;
|
|
179
206
|
export declare function isEventNotRegisteredError(error: unknown): error is EventNotRegisteredError;
|
|
180
207
|
export declare function isSubscriberNotRegisteredError(error: unknown): error is SubscriberNotRegisteredError;
|
|
208
|
+
export declare function isUnknownQueueReferenceError(error: unknown): error is UnknownQueueReferenceError;
|
|
181
209
|
export declare function isMessageMaybePoisonedError(error: unknown): error is MessageMaybePoisonedError;
|
|
182
210
|
export declare function isIdempotentMessageCannotRetryError(error: unknown): error is IdempotentMessageCannotRetryError;
|
|
183
211
|
//# sourceMappingURL=matador-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matador-errors.d.ts","sourceRoot":"","sources":["../../src/errors/matador-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAAsB,YAAa,SAAQ,KAAK;IAC9C;;;OAGG;IACH,SAAiB,IAAI,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAE1B,OAAO,EAAE,MAAM;IAY3B;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlC;AAMD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,QAAQ,CAAC,WAAW,SAGkD;gBAE1D,SAAS,SAAc;CAKpC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,QAAQ,CAAC,WAAW,SAI4C;;CAKjE;AAMD;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,YAAY;aAQxC,aAAa,EAAE,MAAM;IAPvC,QAAQ,CAAC,WAAW,SAI+C;gBAGjD,aAAa,EAAE,MAAM,EACrC,SAAS,SAAc;CAM1B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;aAOxB,aAAa,EAAE,MAAM;IANjD,QAAQ,CAAC,WAAW,SAIkC;gBAE1B,aAAa,EAAE,MAAM;CAKlD;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,YAAY;aAStC,KAAK,EAAE,MAAM;aACb,MAAM,EAAE,SAAS,KAAK,EAAE;IAT1C,QAAQ,CAAC,WAAW,SAK4C;gBAG9C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,KAAK,EA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Q,CAAC,WAAW,SAOyC;gBAG3C,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM;CAMxC;AAED;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,YAAY;aAU/C,OAAO,EAAE,MAAM;aACf,cAAc,EAAE,MAAM;IAVxC,QAAQ,CAAC,WAAW,SAMqD;gBAGvD,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM;CAMzC;AAMD;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;aAS1B,SAAS,EAAE,MAAM;aACjB,SAAS,EAAE,MAAM;IATnC,QAAQ,CAAC,WAAW,SAKyC;gBAG3C,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM;CAIpC;AAMD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,0BAA0B,CAErC;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,uBAAuB,CAElC;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAEvC;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,0BAA0B,CAErC;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,yBAAyB,CAEpC;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iCAAiC,CAE5C"}
|
|
@@ -133,6 +133,25 @@ export class TransportSendError extends MatadorError {
|
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Thrown when send() completes but one or more subscriber publishes failed.
|
|
138
|
+
* The `errors` array contains per-failure details: subscriber name, target queue, and underlying error.
|
|
139
|
+
*/
|
|
140
|
+
export class SomeSendError extends MatadorError {
|
|
141
|
+
eventKey;
|
|
142
|
+
errors;
|
|
143
|
+
description = 'One or more subscriber messages could not be published during send(). ' +
|
|
144
|
+
'ACTION: Inspect the `errors` array for per-failure details. ' +
|
|
145
|
+
'Each entry contains the subscriber name, target queue, and underlying error.';
|
|
146
|
+
constructor(eventKey, errors) {
|
|
147
|
+
const summary = errors
|
|
148
|
+
.map((e) => `${e.subscriberName} (${e.queue}): ${e.error.message}`)
|
|
149
|
+
.join('; ');
|
|
150
|
+
super(`send("${eventKey}") failed for ${errors.length} subscriber(s): ${summary}`);
|
|
151
|
+
this.eventKey = eventKey;
|
|
152
|
+
this.errors = errors;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
136
155
|
/**
|
|
137
156
|
* Thrown when delayed messages are requested but the plugin is not available.
|
|
138
157
|
*/
|
|
@@ -246,6 +265,25 @@ export class LocalTransportCannotProcessStubError extends MatadorError {
|
|
|
246
265
|
// ============================================================================
|
|
247
266
|
// Queue Errors
|
|
248
267
|
// ============================================================================
|
|
268
|
+
/**
|
|
269
|
+
* Thrown when a subscriber's `targetQueue` or a `consumeFrom` entry references
|
|
270
|
+
* a queue that was never declared in the topology.
|
|
271
|
+
*/
|
|
272
|
+
export class UnknownQueueReferenceError extends MatadorError {
|
|
273
|
+
queueName;
|
|
274
|
+
description = 'A queue was referenced that is not declared in the topology. ' +
|
|
275
|
+
'Matador only routes to queues it knows about; an unknown reference would ' +
|
|
276
|
+
'otherwise be silently namespace-qualified and published to a queue nobody ' +
|
|
277
|
+
'consumes, losing the message. ' +
|
|
278
|
+
'ACTION: Declare the queue on the topology before referencing it. ' +
|
|
279
|
+
'For a Matador-owned queue use `.addQueue(name)`; for a foreign queue owned ' +
|
|
280
|
+
'by another service use `.addQueue({ name, exact: true })` so it is routed ' +
|
|
281
|
+
'to verbatim.';
|
|
282
|
+
constructor(queueName) {
|
|
283
|
+
super(`Queue reference "${queueName}" is not declared in the topology. Add it via .addQueue(name), or .addQueue({ name, exact: true }) for a foreign queue.`);
|
|
284
|
+
this.queueName = queueName;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
249
287
|
/**
|
|
250
288
|
* Thrown when a queue is not found or not created.
|
|
251
289
|
*/
|
|
@@ -358,6 +396,9 @@ export function isEventNotRegisteredError(error) {
|
|
|
358
396
|
export function isSubscriberNotRegisteredError(error) {
|
|
359
397
|
return error instanceof SubscriberNotRegisteredError;
|
|
360
398
|
}
|
|
399
|
+
export function isUnknownQueueReferenceError(error) {
|
|
400
|
+
return error instanceof UnknownQueueReferenceError;
|
|
401
|
+
}
|
|
361
402
|
export function isMessageMaybePoisonedError(error) {
|
|
362
403
|
return error instanceof MessageMaybePoisonedError;
|
|
363
404
|
}
|