@ddd-ts-kit/kafka 0.113.2 → 0.115.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/README.fr.md +17 -9
- package/README.md +15 -8
- package/dist/connection/broker-link.d.ts +2 -1
- package/dist/connection/broker-link.d.ts.map +1 -1
- package/dist/connection/broker-link.js +1 -1
- package/dist/connection/broker-link.js.map +1 -1
- package/dist/consumption/group-consumer.d.ts +1 -2
- package/dist/consumption/group-consumer.d.ts.map +1 -1
- package/dist/consumption/group-consumer.js +6 -8
- package/dist/consumption/group-consumer.js.map +1 -1
- package/dist/consumption/group-join.d.ts +17 -0
- package/dist/consumption/group-join.d.ts.map +1 -0
- package/dist/consumption/group-join.js +31 -0
- package/dist/consumption/group-join.js.map +1 -0
- package/dist/errors/start-from-refused-error.d.ts +6 -0
- package/dist/errors/start-from-refused-error.d.ts.map +1 -0
- package/dist/errors/start-from-refused-error.js +9 -0
- package/dist/errors/start-from-refused-error.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/options/kafka-event-bus-options.d.ts +5 -2
- package/dist/options/kafka-event-bus-options.d.ts.map +1 -1
- package/dist/options/settings-of.d.ts.map +1 -1
- package/dist/options/settings-of.js +6 -14
- package/dist/options/settings-of.js.map +1 -1
- package/dist/options/settings.d.ts +2 -1
- package/dist/options/settings.d.ts.map +1 -1
- package/dist/options/start-from.d.ts +5 -0
- package/dist/options/start-from.d.ts.map +1 -0
- package/dist/options/start-from.js +12 -0
- package/dist/options/start-from.js.map +1 -0
- package/package.json +7 -7
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:79853a4c0f4fe3c3 -->
|
|
3
3
|
|
|
4
4
|
# @ddd-ts-kit/kafka
|
|
5
5
|
|
|
@@ -67,7 +67,7 @@ donné à l'application sous la forme de deux ports du noyau : `IntegrationEvent
|
|
|
67
67
|
l'outbox, et `EventSubscribers` remet à chaque contexte l'abonné de son propre nom de
|
|
68
68
|
consommateur.
|
|
69
69
|
|
|
70
|
-
, qui l'écrit dans le topic de son type, avec pour clé l'id de la commande ; chaque contexte consommateur est un groupe de consommateurs, notifications et billing reçoivent tous deux chaque événement, les deux instances de billing se partagent les partitions ; le gestionnaire de billing valide sa marque et son travail en une unité de travail avant que l'offset soit validé ; un enregistrement qui échoue encore et encore part dans le topic de rejet de billing](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/kafka-place-in-an-application.fr.svg)
|
|
71
71
|
|
|
72
72
|
`init --broker kafka` écrit ce câblage dans la plateforme du projet : le bus est construit par
|
|
73
73
|
`platform/events/create-event-provider.ts`, avec la clé de `platform/events/aggregate-key-of.ts`,
|
|
@@ -289,7 +289,7 @@ Kafka ordonne les enregistrements d'une partition, et la clé choisit la partiti
|
|
|
289
289
|
les dupliquer), un consommateur traite les enregistrements d'une partition un à la fois, et
|
|
290
290
|
un enregistrement en échec est retenté **sur place**, voir plus bas.
|
|
291
291
|
|
|
292
|
-

|
|
293
293
|
|
|
294
294
|
<!-- checked sample -->
|
|
295
295
|
```ts
|
|
@@ -343,7 +343,13 @@ les enregistrements d'une partition ne sont jamais traités en parallèle.
|
|
|
343
343
|
4. Un enregistrement dont la valeur n'est pas une enveloppe (illisible, ou sans `id`, `type`,
|
|
344
344
|
`version`, `occurredAt`) est empoisonné : il part directement dans le *topic* de rejet avec
|
|
345
345
|
`x-dead-reason: poison` et `x-error-code: POISON_MESSAGE`, et aucun gestionnaire ne le voit.
|
|
346
|
-
5.
|
|
346
|
+
5. Un enregistrement dont le type n'a plus de gestionnaire (ils se sont tous désabonnés) attend
|
|
347
|
+
le prochain gestionnaire : sa partition est mise en pause jusqu'à ce qu'un gestionnaire
|
|
348
|
+
s'abonne ou que le bus se ferme, il ne compte pour aucune tentative et ne part jamais dans le
|
|
349
|
+
*topic* de rejet pour cela. Les quatre brokers du kit gardent un tel message pour le prochain
|
|
350
|
+
gestionnaire. Un enregistrement d'un type auquel le consommateur ne s'est jamais abonné, sur
|
|
351
|
+
un *topic* que plusieurs types partagent, est validé sans être traité.
|
|
352
|
+
6. Seuls des codes circulent : `x-error-code` est le `code` de l'erreur ou le nom de sa classe.
|
|
347
353
|
Le message d'une erreur n'est jamais journalisé, signalé ni joint, parce qu'il peut citer des
|
|
348
354
|
données de la charge utile. Le client journalise les messages et les piles de ce qu'il
|
|
349
355
|
attrape : le bus coupe son *logger*.
|
|
@@ -359,7 +365,7 @@ sont traités sans lui, et un rejeu le ramène en retard. Un consommateur qui ne
|
|
|
359
365
|
tolérer doit s'arrêter lui-même sur le rejet (porter une version dans la charge utile, refuser
|
|
360
366
|
un trou).
|
|
361
367
|
|
|
362
|
-

|
|
363
369
|
|
|
364
370
|
Le bus décide d'après ce que fait le gestionnaire : un gestionnaire qui cache son échec le cache
|
|
365
371
|
aussi au bus.
|
|
@@ -511,10 +517,12 @@ que le bus se ferme.
|
|
|
511
517
|
5 minutes par défaut). Au-delà, le membre est tenu pour mort, ses partitions changent de main,
|
|
512
518
|
et l'enregistrement est traité deux fois, en parallèle.
|
|
513
519
|
- **Un nouveau groupe commence au plus ancien enregistrement** de ses *topics*
|
|
514
|
-
(`startFrom: '
|
|
515
|
-
consommateur
|
|
516
|
-
|
|
517
|
-
|
|
520
|
+
(`startFrom: 'beginning'`, la valeur par défaut de chaque broker du kit qui a un historique) :
|
|
521
|
+
un consommateur déployé après les producteurs ne manque rien, et un consommateur ajouté un an
|
|
522
|
+
plus tard lit un an d'événements retenus. Choisissez `startFrom: 'end'` en connaissance de
|
|
523
|
+
cause, en sachant que ce qui est publié entre la création du groupe et sa première affectation
|
|
524
|
+
est alors sauté. Les anciens mots `earliest` et `latest` sont refusés à la construction avec
|
|
525
|
+
`START_FROM_REFUSED`, qui nomme le nouveau.
|
|
518
526
|
- **Une nouvelle tentative exécute de nouveau tous les gestionnaires du type**, y compris ceux
|
|
519
527
|
qui ont réussi, quand plusieurs gestionnaires d'un même consommateur sont abonnés au même
|
|
520
528
|
type. Chacun doit être idempotent.
|
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ each consuming context listens through the bus under its own name. The bus is gi
|
|
|
61
61
|
application as two ports of the kernel: `IntegrationEventPublisher` stays the outbox, and
|
|
62
62
|
`EventSubscribers` hands each context the subscriber of its own consumer name.
|
|
63
63
|
|
|
64
|
-
, which writes it to the topic of its type, keyed by the order id; each consuming context is a consumer group, notifications and billing both receive every event, the two instances of billing share the partitions; the billing handler commits its mark and its work in one unit of work before the offset is committed; a record that keeps failing goes to the dead-letter topic of billing](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/kafka-place-in-an-application.svg)
|
|
65
65
|
|
|
66
66
|
`init --broker kafka` writes this wiring in the platform of the project: the bus is built by
|
|
67
67
|
`platform/events/create-event-provider.ts`, keyed by `platform/events/aggregate-key-of.ts`,
|
|
@@ -280,7 +280,7 @@ Kafka orders the records of one partition, and the key chooses the partition. So
|
|
|
280
280
|
consumer handles the records of a partition one at a time, and a failed record is retried
|
|
281
281
|
**in place**, see below.
|
|
282
282
|
|
|
283
|
-

|
|
284
284
|
|
|
285
285
|
<!-- checked sample -->
|
|
286
286
|
```ts
|
|
@@ -332,7 +332,12 @@ of one partition are never handled concurrently.
|
|
|
332
332
|
4. A record whose value is not an envelope (unparseable, or without `id`, `type`, `version`,
|
|
333
333
|
`occurredAt`) is poison: it goes straight to the dead-letter topic with
|
|
334
334
|
`x-dead-reason: poison` and `x-error-code: POISON_MESSAGE`, and no handler sees it.
|
|
335
|
-
5.
|
|
335
|
+
5. A record whose type has no handler left (they all unsubscribed) waits for the next handler:
|
|
336
|
+
its partition is paused until one subscribes or the bus closes, it counts as no attempt and
|
|
337
|
+
never goes to the dead-letter topic for it. The four brokers of the kit keep such a message
|
|
338
|
+
for the next handler. A record of a type the consumer never subscribed to, on a topic several
|
|
339
|
+
types share, is committed unhandled.
|
|
340
|
+
6. Only codes travel: `x-error-code` is the `code` of the error or its class name. The message
|
|
336
341
|
of an error is never logged, reported or attached, because it may quote payload data. The
|
|
337
342
|
client logs messages and stacks of what it catches: the bus turns its logger off.
|
|
338
343
|
|
|
@@ -346,7 +351,7 @@ that follow a dead one are handled without it, and a replay brings it back late.
|
|
|
346
351
|
that cannot tolerate that must stop on the dead letter itself (carry a version in the
|
|
347
352
|
payload, refuse a gap).
|
|
348
353
|
|
|
349
|
-

|
|
350
355
|
|
|
351
356
|
The bus decides from what the handler does, so a handler that hides its failure hides it from
|
|
352
357
|
the bus too:
|
|
@@ -487,10 +492,12 @@ holds its partition until a handler comes back or the bus closes.
|
|
|
487
492
|
- **A handler must finish within `maxHandlingMs`** (`max.poll.interval.ms`, 5 minutes by
|
|
488
493
|
default). Beyond it the member is taken for dead, its partitions move, and the record is
|
|
489
494
|
handled twice, concurrently.
|
|
490
|
-
- **A new group starts at the earliest record** of its topics (`startFrom: '
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
495
|
+
- **A new group starts at the earliest record** of its topics (`startFrom: 'beginning'`, the
|
|
496
|
+
default of every broker of the kit that has a history): a consumer deployed after the
|
|
497
|
+
producers misses nothing, and a consumer added a year later reads a year of retained events.
|
|
498
|
+
Choose `startFrom: 'end'` deliberately, knowing that what is published between the creation
|
|
499
|
+
of the group and its first assignment is then skipped. The former words `earliest` and
|
|
500
|
+
`latest` are refused at construction with `START_FROM_REFUSED`, which names the new one.
|
|
494
501
|
- **A retry runs every handler of the type again**, those that succeeded included, when
|
|
495
502
|
several handlers of one consumer subscribe to the same type. Each must be idempotent.
|
|
496
503
|
- **A batch is not atomic.** When `publish` rejects, some records may have been written. The
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { inspect } from 'node:util';
|
|
2
2
|
import { KafkaJS } from '@confluentinc/kafka-javascript';
|
|
3
3
|
import type { TopicDescription } from '../topology/topic-description.js';
|
|
4
|
+
import type { StartFrom } from '../options/start-from.js';
|
|
4
5
|
import type { Rebalance } from './rebalance.js';
|
|
5
6
|
export interface LinkSettings {
|
|
6
7
|
readonly createTopics: boolean;
|
|
7
|
-
readonly
|
|
8
|
+
readonly startFrom: StartFrom;
|
|
8
9
|
readonly publishTimeoutMs: number;
|
|
9
10
|
readonly connectTimeoutMs: number;
|
|
10
11
|
readonly maxHandlingMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-link.d.ts","sourceRoot":"","sources":["../../src/connection/broker-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAOzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"broker-link.d.ts","sourceRoot":"","sources":["../../src/connection/broker-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAOzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM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ED,MAAM,IAAI,MAAM,CAEf;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAEzB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-link.js","sourceRoot":"","sources":["../../src/connection/broker-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"broker-link.js","sourceRoot":"","sources":["../../src/connection/broker-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAkB7C,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC;AAC3D,MAAM,WAAW,GAAG,gCAAgC,CAAC;AA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,CAAC,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -35,8 +35,7 @@ export declare class GroupConsumer {
|
|
|
35
35
|
private client;
|
|
36
36
|
private running;
|
|
37
37
|
private work;
|
|
38
|
-
private
|
|
39
|
-
private join;
|
|
38
|
+
private readonly join;
|
|
40
39
|
private draining;
|
|
41
40
|
constructor(name: string, dependencies: GroupDependencies);
|
|
42
41
|
get inFlight(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-consumer.d.ts","sourceRoot":"","sources":["../../src/consumption/group-consumer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"group-consumer.d.ts","sourceRoot":"","sources":["../../src/consumption/group-consumer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,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mB;IAExC,OAAO,CAAC,QAAQ,CAAS;IAEzB,YACW,IAAI,EAAE,MAAM,EACJ,YAAY,EAAE,iBAAiB,EAiBjD;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,kBAAkB,IAAI,MAAM,CAE/B;IAED,KAAK,IAAI,MAAM,EAAE,CAEhB;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,YAAY,CAOjE;IAED,kGAAkG;IAC5F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAG7B;IAED,wFAAwF;IAClF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ3B;IAED,OAAO,CAAC,WAAW;YAIL,gBAAgB;IAqB9B,OAAO,CAAC,QAAQ;YAMF,SAAS;IAYvB,OAAO,CAAC,UAAU;YAUJ,GAAG;YAaH,OAAO;IAQrB,OAAO,CAAC,YAAY;CAgBrB"}
|
|
@@ -2,6 +2,7 @@ import { reasonOf } from '../errors/reason-of.js';
|
|
|
2
2
|
import { ignore } from '../ignore.js';
|
|
3
3
|
import { topologyOf } from '../topology/topology-of.js';
|
|
4
4
|
import { Backoff } from './backoff.js';
|
|
5
|
+
import { GroupJoin } from './group-join.js';
|
|
5
6
|
import { postpone } from './postpone.js';
|
|
6
7
|
import { RecordHandling } from './record-handling.js';
|
|
7
8
|
import { Timers } from './timers.js';
|
|
@@ -21,8 +22,7 @@ export class GroupConsumer {
|
|
|
21
22
|
client;
|
|
22
23
|
running = false;
|
|
23
24
|
work = Promise.resolve();
|
|
24
|
-
|
|
25
|
-
join = ignore;
|
|
25
|
+
join = new GroupJoin();
|
|
26
26
|
draining = false;
|
|
27
27
|
constructor(name, dependencies) {
|
|
28
28
|
this.name = name;
|
|
@@ -59,7 +59,7 @@ export class GroupConsumer {
|
|
|
59
59
|
/** Resolves once the group has its partitions for the subscriptions made so far, or failed to. */
|
|
60
60
|
async started() {
|
|
61
61
|
await this.work;
|
|
62
|
-
await this.
|
|
62
|
+
await this.join.over();
|
|
63
63
|
}
|
|
64
64
|
/** Stops reading, lets the handlers in progress finish and commit, leaves the group. */
|
|
65
65
|
async drain() {
|
|
@@ -82,9 +82,7 @@ export class GroupConsumer {
|
|
|
82
82
|
try {
|
|
83
83
|
await this.dependencies.link.declare(this.topology().topics);
|
|
84
84
|
const client = await this.connected();
|
|
85
|
-
this.
|
|
86
|
-
this.join = resolve;
|
|
87
|
-
});
|
|
85
|
+
this.join.asked();
|
|
88
86
|
await client.subscribe({ topics: pending });
|
|
89
87
|
await this.run(client);
|
|
90
88
|
pending.forEach((topic) => this.subscribed.add(topic));
|
|
@@ -107,7 +105,7 @@ export class GroupConsumer {
|
|
|
107
105
|
}
|
|
108
106
|
rebalanced({ assigned, partitions }) {
|
|
109
107
|
if (assigned) {
|
|
110
|
-
this.join();
|
|
108
|
+
this.join.settled();
|
|
111
109
|
return;
|
|
112
110
|
}
|
|
113
111
|
this.records.forget(partitions);
|
|
@@ -135,7 +133,7 @@ export class GroupConsumer {
|
|
|
135
133
|
this.running = false;
|
|
136
134
|
this.subscribed.clear();
|
|
137
135
|
void client?.disconnect().catch(ignore);
|
|
138
|
-
this.join();
|
|
136
|
+
this.join.settled();
|
|
139
137
|
this.timers.later(() => {
|
|
140
138
|
this.synchronize();
|
|
141
139
|
}, this.backoff.delayMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-consumer.js","sourceRoot":"","sources":["../../src/consumption/group-consumer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAOnC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,C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C;YACf,8BAA8B,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW;YACtE,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,QAAoC;QACxD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,KAAK,MAAM,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;YACrB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEzB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wait of a member for the partitions the group owes it. A subscription added while the
|
|
3
|
+
* group joins waits for the same answer: there is one wait at a time, so whoever asked first
|
|
4
|
+
* is told with the others, and nobody holds a promise that no assignment resolves.
|
|
5
|
+
*/
|
|
6
|
+
export declare class GroupJoin {
|
|
7
|
+
private answered;
|
|
8
|
+
private answer;
|
|
9
|
+
private awaited;
|
|
10
|
+
/** The member asked the group for partitions: it waits, unless it already does. */
|
|
11
|
+
asked(): void;
|
|
12
|
+
/** The partitions came, or the member gave the join up. */
|
|
13
|
+
settled(): void;
|
|
14
|
+
/** Resolves once the member waits for no partition. */
|
|
15
|
+
over(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=group-join.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-join.d.ts","sourceRoot":"","sources":["../../src/consumption/group-join.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAoC;IAEpD,OAAO,CAAC,MAAM,CAAsB;IAEpC,OAAO,CAAC,OAAO,CAAS;IAExB,mFAAmF;IACnF,KAAK,IAAI,IAAI,CAUZ;IAED,2DAA2D;IAC3D,OAAO,IAAI,IAAI,CAGd;IAED,uDAAuD;IACvD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpB;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ignore } from '../ignore.js';
|
|
2
|
+
/**
|
|
3
|
+
* The wait of a member for the partitions the group owes it. A subscription added while the
|
|
4
|
+
* group joins waits for the same answer: there is one wait at a time, so whoever asked first
|
|
5
|
+
* is told with the others, and nobody holds a promise that no assignment resolves.
|
|
6
|
+
*/
|
|
7
|
+
export class GroupJoin {
|
|
8
|
+
answered = Promise.resolve();
|
|
9
|
+
answer = ignore;
|
|
10
|
+
awaited = false;
|
|
11
|
+
/** The member asked the group for partitions: it waits, unless it already does. */
|
|
12
|
+
asked() {
|
|
13
|
+
if (this.awaited) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.awaited = true;
|
|
17
|
+
this.answered = new Promise((resolve) => {
|
|
18
|
+
this.answer = resolve;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** The partitions came, or the member gave the join up. */
|
|
22
|
+
settled() {
|
|
23
|
+
this.awaited = false;
|
|
24
|
+
this.answer();
|
|
25
|
+
}
|
|
26
|
+
/** Resolves once the member waits for no partition. */
|
|
27
|
+
over() {
|
|
28
|
+
return this.answered;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=group-join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-join.js","sourceRoot":"","sources":["../../src/consumption/group-join.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACZ,QAAQ,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAE5C,MAAM,GAAe,MAAM,CAAC;IAE5B,OAAO,GAAG,KAAK,CAAC;IAExB,mFAAmF;IACnF,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2DAA2D;IAC3D,OAAO;QACL,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,uDAAuD;IACvD,IAAI;QACF,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** `startFrom` was given a word it does not take: one it took before the brokers shared a vocabulary, or an unknown one. */
|
|
2
|
+
export declare class StartFromRefusedError extends Error {
|
|
3
|
+
readonly code = "START_FROM_REFUSED";
|
|
4
|
+
constructor(given: string, replacement?: string);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=start-from-refused-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-from-refused-error.d.ts","sourceRoot":"","sources":["../../src/errors/start-from-refused-error.ts"],"names":[],"mappings":"AAAA,4HAA4H;AAC5H,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,wBAAwB;IAErC,YAAY,KAAK,EAAE,MAAM,EAAE,WAAW,SAAyB,EAI9D;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** `startFrom` was given a word it does not take: one it took before the brokers shared a vocabulary, or an unknown one. */
|
|
2
|
+
export class StartFromRefusedError extends Error {
|
|
3
|
+
code = 'START_FROM_REFUSED';
|
|
4
|
+
constructor(given, replacement = "'beginning' or 'end'") {
|
|
5
|
+
super(`startFrom: '${given}' is refused: write startFrom: ${replacement}`);
|
|
6
|
+
this.name = 'StartFromRefusedError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=start-from-refused-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-from-refused-error.js","sourceRoot":"","sources":["../../src/errors/start-from-refused-error.ts"],"names":[],"mappings":"AAAA,4HAA4H;AAC5H,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,IAAI,GAAG,oBAAoB,CAAC;IAErC,YAAY,KAAa,EAAE,WAAW,GAAG,sBAAsB;QAC7D,KAAK,CAAC,eAAe,KAAK,kCAAkC,WAAW,EAAE,CAAC,CAAC;QAE3E,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { KafkaDelivery } from './options/kafka-delivery.js';
|
|
|
4
4
|
export type { KafkaFailure } from './options/kafka-failure.js';
|
|
5
5
|
export type { ReconnectOptions } from './options/reconnect-options.js';
|
|
6
6
|
export type { RetryOptions } from './options/retry-options.js';
|
|
7
|
+
export type { StartFrom } from './options/start-from.js';
|
|
7
8
|
export type { TopicOptions } from './options/topic-options.js';
|
|
8
9
|
export { deadTopicOf } from './topology/dead-topic-of.js';
|
|
9
10
|
export { replayGroupOf } from './topology/replay-group-of.js';
|
|
@@ -17,4 +18,5 @@ export { BrokerUnavailableError } from './errors/broker-unavailable-error.js';
|
|
|
17
18
|
export { ConsumerNameRequiredError } from './errors/consumer-name-required-error.js';
|
|
18
19
|
export { EventBusClosedError } from './errors/event-bus-closed-error.js';
|
|
19
20
|
export { PublishNotAcknowledgedError } from './errors/publish-not-acknowledged-error.js';
|
|
21
|
+
export { StartFromRefusedError } from './errors/start-from-refused-error.js';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,2B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,2BAA2B,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,5 @@ export { BrokerUnavailableError } from './errors/broker-unavailable-error.js';
|
|
|
7
7
|
export { ConsumerNameRequiredError } from './errors/consumer-name-required-error.js';
|
|
8
8
|
export { EventBusClosedError } from './errors/event-bus-closed-error.js';
|
|
9
9
|
export { PublishNotAcknowledgedError } from './errors/publish-not-acknowledged-error.js';
|
|
10
|
+
export { StartFromRefusedError } from './errors/start-from-refused-error.js';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAQlD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAK3D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -29,8 +29,11 @@ export interface KafkaEventBusOptions {
|
|
|
29
29
|
/** Event types this service publishes: `assertTopology` creates their topics at startup. */
|
|
30
30
|
readonly publishedTypes?: readonly string[];
|
|
31
31
|
readonly topics?: TopicOptions;
|
|
32
|
-
/**
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Where a consumer group that has no committed offset starts: the earliest record its topics
|
|
34
|
+
* hold, or `end` for what is published from then on. Default `beginning`, as on the other brokers.
|
|
35
|
+
*/
|
|
36
|
+
readonly startFrom?: 'beginning' | 'end';
|
|
34
37
|
/** Partitions a consumer handles at once; records of one partition are never concurrent. Default 1. */
|
|
35
38
|
readonly concurrency?: number;
|
|
36
39
|
/** Time the in-sync replicas have to acknowledge a record before `publish` rejects. Default 30000. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kafka-event-bus-options.d.ts","sourceRoot":"","sources":["../../src/options/kafka-event-bus-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAA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CAAC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACrD,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;CACzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-of.d.ts","sourceRoot":"","sources":["../../src/options/settings-of.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings-of.d.ts","sourceRoot":"","sources":["../../src/options/settings-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,GAAG,QAAQ,CAkBlE"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { safely } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { startFromOf } from './start-from.js';
|
|
1
3
|
export function settingsOf(options) {
|
|
2
4
|
return {
|
|
3
5
|
consumer: options.consumer,
|
|
@@ -5,15 +7,16 @@ export function settingsOf(options) {
|
|
|
5
7
|
keyOf: options.keyOf ?? ((event) => event.id),
|
|
6
8
|
publishedTypes: options.publishedTypes ?? [],
|
|
7
9
|
topics: topicsOf(options.topics),
|
|
8
|
-
|
|
10
|
+
startFrom: startFromOf(options.startFrom ?? 'beginning'),
|
|
9
11
|
concurrency: options.concurrency ?? 1,
|
|
10
12
|
publishTimeoutMs: options.publishTimeoutMs ?? 30_000,
|
|
11
13
|
connectTimeoutMs: options.connectTimeoutMs ?? 10_000,
|
|
12
14
|
maxHandlingMs: options.maxHandlingMs ?? 300_000,
|
|
13
15
|
retry: retryOf(options.retry),
|
|
14
16
|
reconnect: reconnectOf(options.reconnect),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
// A hook that throws must not leave a record uncommitted or stop a consumer.
|
|
18
|
+
onFailure: (failure) => safely(() => options.onFailure?.(failure)),
|
|
19
|
+
onDelivery: (delivery) => safely(() => options.onDelivery?.(delivery)),
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
22
|
function topicsOf(topics = {}) {
|
|
@@ -33,15 +36,4 @@ function reconnectOf(reconnect = {}) {
|
|
|
33
36
|
maxMs: reconnect.maxMs ?? 30_000,
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
|
-
// A hook that throws must not leave a record uncommitted or stop a consumer.
|
|
37
|
-
function guarded(hook) {
|
|
38
|
-
return (value) => {
|
|
39
|
-
try {
|
|
40
|
-
hook?.(value);
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
39
|
//# sourceMappingURL=settings-of.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-of.js","sourceRoot":"","sources":["../../src/options/settings-of.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings-of.js","sourceRoot":"","sources":["../../src/options/settings-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAK5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,UAAU,UAAU,CAAC,OAA6B;IACtD,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;QAC5C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,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nD,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,GAAG;QACrC,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC;QAC7B,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,MAAM;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -3,6 +3,7 @@ import type { KafkaDelivery } from './kafka-delivery.js';
|
|
|
3
3
|
import type { KafkaFailure } from './kafka-failure.js';
|
|
4
4
|
import type { ReconnectOptions } from './reconnect-options.js';
|
|
5
5
|
import type { RetryOptions } from './retry-options.js';
|
|
6
|
+
import type { StartFrom } from './start-from.js';
|
|
6
7
|
import type { TopicOptions } from './topic-options.js';
|
|
7
8
|
/**
|
|
8
9
|
* The options of a bus with every default applied. The brokers and the client properties are
|
|
@@ -14,7 +15,7 @@ export interface Settings {
|
|
|
14
15
|
readonly keyOf: (event: IntegrationEvent) => string | undefined;
|
|
15
16
|
readonly publishedTypes: readonly string[];
|
|
16
17
|
readonly topics: Required<TopicOptions>;
|
|
17
|
-
readonly
|
|
18
|
+
readonly startFrom: StartFrom;
|
|
18
19
|
readonly concurrency: number;
|
|
19
20
|
readonly publishTimeoutMs: number;
|
|
20
21
|
readonly connectTimeoutMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/options/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,MA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;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;CACxD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Where a consumer group that has no position yet starts: the whole history, or what is published from then on. */
|
|
2
|
+
export type StartFrom = 'beginning' | 'end';
|
|
3
|
+
/** The word as given, when it is one the option takes; a former or an unknown word is refused by name. */
|
|
4
|
+
export declare function startFromOf(given: string): StartFrom;
|
|
5
|
+
//# sourceMappingURL=start-from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-from.d.ts","sourceRoot":"","sources":["../../src/options/start-from.ts"],"names":[],"mappings":"AAEA,oHAAoH;AACpH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,KAAK,CAAC;AAK5C,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAQpD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StartFromRefusedError } from '../errors/start-from-refused-error.js';
|
|
2
|
+
/** The words the option took before the brokers shared one vocabulary, each with the word that replaced it. */
|
|
3
|
+
const FORMER = { earliest: 'beginning', latest: 'end' };
|
|
4
|
+
/** The word as given, when it is one the option takes; a former or an unknown word is refused by name. */
|
|
5
|
+
export function startFromOf(given) {
|
|
6
|
+
if (given === 'beginning' || given === 'end') {
|
|
7
|
+
return given;
|
|
8
|
+
}
|
|
9
|
+
const replacement = FORMER[given];
|
|
10
|
+
throw new StartFromRefusedError(given, replacement === undefined ? undefined : `'${replacement}'`);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=start-from.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-from.js","sourceRoot":"","sources":["../../src/options/start-from.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAK3E,+GAA+G;AAC/G,MAAM,MAAM,GAAwC,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAE7F,0GAA0G;AAC1G,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAElC,MAAM,IAAI,qBAAqB,CAAC,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC;AACrG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/kafka",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.115.0",
|
|
4
4
|
"description": "Kafka provider for integration events: idempotent keyed publishing for the outbox relay, one consumer group per consumer, offsets committed after handling, bounded retries and a dead-letter topic.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/
|
|
20
|
+
"url": "git+https://github.com/ddd-ts-kit/ddd-ts-kit.git",
|
|
21
21
|
"directory": "packages/kafka"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://
|
|
24
|
-
"bugs": "https://github.com/
|
|
23
|
+
"homepage": "https://ddd-ts-kit.github.io/ddd-ts-kit/packages/kafka/",
|
|
24
|
+
"bugs": "https://github.com/ddd-ts-kit/ddd-ts-kit/issues",
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public",
|
|
27
27
|
"provenance": true
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@ddd-ts-kit/events": "0.
|
|
45
|
-
"@ddd-ts-kit/kernel": "0.
|
|
44
|
+
"@ddd-ts-kit/events": "0.115.0",
|
|
45
|
+
"@ddd-ts-kit/kernel": "0.115.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@confluentinc/kafka-javascript": "^1.11.0",
|
|
49
|
-
"@ddd-ts-kit/testing": "0.
|
|
49
|
+
"@ddd-ts-kit/testing": "0.115.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@confluentinc/kafka-javascript": ">=1.11.0 <2"
|