@laserdata/laser-sdk 0.5.0 → 0.5.2

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.
Files changed (75) hide show
  1. package/README.md +21 -14
  2. package/dist/agent/reliable-consumer.d.ts.map +1 -1
  3. package/dist/agent/reliable-consumer.js +4 -5
  4. package/dist/agent/reliable-consumer.js.map +1 -1
  5. package/dist/bridges/a2a.d.ts +1 -1
  6. package/dist/bridges/a2a.js +1 -1
  7. package/dist/client/capabilities.d.ts +12 -0
  8. package/dist/client/capabilities.d.ts.map +1 -1
  9. package/dist/client/capabilities.js +13 -5
  10. package/dist/client/capabilities.js.map +1 -1
  11. package/dist/client/errors.d.ts +14 -1
  12. package/dist/client/errors.d.ts.map +1 -1
  13. package/dist/client/errors.js +20 -0
  14. package/dist/client/errors.js.map +1 -1
  15. package/dist/client/internals.d.ts +1 -0
  16. package/dist/client/internals.d.ts.map +1 -1
  17. package/dist/client/internals.js +1 -0
  18. package/dist/client/internals.js.map +1 -1
  19. package/dist/client/laser.d.ts +1 -6
  20. package/dist/client/laser.d.ts.map +1 -1
  21. package/dist/client/laser.js +39 -30
  22. package/dist/client/laser.js.map +1 -1
  23. package/dist/iggy/apache-iggy.d.ts +3 -0
  24. package/dist/iggy/apache-iggy.d.ts.map +1 -1
  25. package/dist/iggy/apache-iggy.js +6 -1
  26. package/dist/iggy/apache-iggy.js.map +1 -1
  27. package/dist/index.d.ts +6 -4
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/managed/filters.d.ts +57 -128
  32. package/dist/managed/filters.d.ts.map +1 -1
  33. package/dist/managed/filters.js +292 -271
  34. package/dist/managed/filters.js.map +1 -1
  35. package/dist/stream/consumer-group.d.ts +168 -0
  36. package/dist/stream/consumer-group.d.ts.map +1 -0
  37. package/dist/stream/consumer-group.js +411 -0
  38. package/dist/stream/consumer-group.js.map +1 -0
  39. package/dist/stream/consumer.d.ts +38 -5
  40. package/dist/stream/consumer.d.ts.map +1 -1
  41. package/dist/stream/consumer.js +161 -37
  42. package/dist/stream/consumer.js.map +1 -1
  43. package/dist/stream/producer-statistics.d.ts +22 -0
  44. package/dist/stream/producer-statistics.d.ts.map +1 -0
  45. package/dist/stream/producer-statistics.js +214 -0
  46. package/dist/stream/producer-statistics.js.map +1 -0
  47. package/dist/stream/producer.d.ts +2 -0
  48. package/dist/stream/producer.d.ts.map +1 -1
  49. package/dist/stream/producer.js +16 -0
  50. package/dist/stream/producer.js.map +1 -1
  51. package/dist/stream/stream.d.ts +3 -1
  52. package/dist/stream/stream.d.ts.map +1 -1
  53. package/dist/stream/stream.js +4 -2
  54. package/dist/stream/stream.js.map +1 -1
  55. package/dist/stream/topic.d.ts +19 -3
  56. package/dist/stream/topic.d.ts.map +1 -1
  57. package/dist/stream/topic.js +29 -6
  58. package/dist/stream/topic.js.map +1 -1
  59. package/dist/wire/filter.d.ts +66 -3
  60. package/dist/wire/filter.d.ts.map +1 -1
  61. package/dist/wire/filter.js +195 -27
  62. package/dist/wire/filter.js.map +1 -1
  63. package/dist/wire/hello.d.ts +1 -0
  64. package/dist/wire/hello.d.ts.map +1 -1
  65. package/dist/wire/hello.js +2 -1
  66. package/dist/wire/hello.js.map +1 -1
  67. package/dist/wire/http.d.ts +1 -0
  68. package/dist/wire/http.d.ts.map +1 -1
  69. package/dist/wire/http.js +2 -0
  70. package/dist/wire/http.js.map +1 -1
  71. package/dist/wire/limits.d.ts +2 -0
  72. package/dist/wire/limits.d.ts.map +1 -1
  73. package/dist/wire/limits.js +2 -0
  74. package/dist/wire/limits.js.map +1 -1
  75. package/package.json +1 -1
@@ -0,0 +1,411 @@
1
+ import { ConsumerGroupSetupError, FilterExecutionError, InvalidError, TransportError, UnsupportedError } from "../client/errors.js";
2
+ import { INTERNAL_NATIVE_CONSUMER } from "../client/internals.js";
3
+ import { FilteredReaderBuilder, Filters, nativeGroup } from "../managed/filters.js";
4
+ import { Consumer, resolveConsumerOptions } from "./consumer.js";
5
+ /**
6
+ * One consumer group of a topic. The group owns its filter policy: consumers
7
+ * and readers built from this handle run whatever the group is configured
8
+ * with, a filter or none, and never name a filter themselves. Build it with
9
+ * `Topic.consumerGroup` or `Topic.consumerGroupId`.
10
+ */
11
+ export class ConsumerGroup {
12
+ transport;
13
+ streamName;
14
+ topicName;
15
+ target;
16
+ context;
17
+ // The control-log position of the last configuration this handle performed.
18
+ // Every read built from the handle carries it, so the application never
19
+ // observes its own configuration as absent through another node.
20
+ configuredAt;
21
+ constructor(transport, streamName, topicName, target, context) {
22
+ this.transport = transport;
23
+ this.streamName = streamName;
24
+ this.topicName = topicName;
25
+ this.target = target;
26
+ this.context = context;
27
+ if (target.kind === "id" && (target.id < 0n || target.id > 0xffffffffn)) {
28
+ throw new InvalidError("consumer group id exceeds 32 bits");
29
+ }
30
+ }
31
+ /** The group name, `undefined` for a handle addressed by numeric id. */
32
+ get name() {
33
+ return this.target.kind === "name" ? this.target.name : undefined;
34
+ }
35
+ /** The native numeric id, `undefined` for a handle addressed by name. */
36
+ get id() {
37
+ return this.target.kind === "id" ? this.target.id : undefined;
38
+ }
39
+ /**
40
+ * Create the group, with an optional filter policy configured in the same
41
+ * call. Idempotent: an existing group is kept, and the same policy keeps its
42
+ * binding. A policy is preflighted against the server's capabilities before
43
+ * the native group is created. A group that runs another policy throws
44
+ * `ConsumerGroupSetupError` with reason `conflict`, and the group is left as
45
+ * it is.
46
+ */
47
+ async create(options = {}) {
48
+ if (this.target.kind !== "name") {
49
+ throw new InvalidError("a consumer group is created by name, address it with consumerGroup(name)");
50
+ }
51
+ if (options.filter !== undefined && options.policy !== undefined) {
52
+ throw new InvalidError("pass either `filter` or `policy`");
53
+ }
54
+ const policy = options.policy ??
55
+ (options.filter !== undefined ? { kind: "definition", filter: options.filter } : undefined);
56
+ if (policy !== undefined)
57
+ await this.filters().requireCatalog();
58
+ await this.transport.ensureConsumerGroup(this.streamName, this.topicName, this.target.name);
59
+ const native = await this.native();
60
+ if (policy === undefined)
61
+ return this.described(native);
62
+ try {
63
+ const configured = await this.filters().configureGroup({ stream: this.streamName, topic: this.topicName, group: native.name }, policy, options.operationId, native.identity);
64
+ requireSameGroup(native.identity, configured.binding.identity);
65
+ this.remember(configured.catalogPosition);
66
+ return {
67
+ id: native.id,
68
+ name: native.name,
69
+ identity: native.identity,
70
+ filter: configured.binding
71
+ };
72
+ }
73
+ catch (cause) {
74
+ throw new ConsumerGroupSetupError(native.id, native.name, native.identity, cause);
75
+ }
76
+ }
77
+ /** The group as the server knows it: its id, exact identity and active policy. */
78
+ async info() {
79
+ return this.described(await this.native());
80
+ }
81
+ /**
82
+ * The group's filter policy: configure it, inspect it, draft and pause
83
+ * revisions, release it, preview and sample-test it.
84
+ */
85
+ filter() {
86
+ return GroupFilter.create({
87
+ streamName: this.streamName,
88
+ topicName: this.topicName,
89
+ filters: () => this.filters(),
90
+ groupRef: () => this.groupRef(),
91
+ native: () => this.native(),
92
+ remember: (position) => {
93
+ this.remember(position);
94
+ }
95
+ });
96
+ }
97
+ /**
98
+ * Build a live, load-balanced consumer of this group. On a server that
99
+ * resolves group policies the consumer runs the group's filter, or none, and
100
+ * commits through the group's fenced acknowledgments. On Apache Iggy it is
101
+ * the native group consumer. A server that serves filters without group
102
+ * reads is refused with `UnsupportedError`, and a capability probe that
103
+ * established nothing is a retryable `TransportError`, never a native read.
104
+ */
105
+ async consumer(options = {}) {
106
+ const capabilities = await this.context?.capabilities();
107
+ if (capabilities === undefined) {
108
+ throw new TransportError("consumer group policies require capability negotiation, build the topic from a Laser client", true);
109
+ }
110
+ if (!policyAware(capabilities)) {
111
+ return this[INTERNAL_NATIVE_CONSUMER](options);
112
+ }
113
+ const resolved = resolveConsumerOptions(options, false);
114
+ if (this.target.kind === "name") {
115
+ await this.transport.ensureConsumerGroup(this.streamName, this.topicName, this.target.name);
116
+ }
117
+ const name = this.target.kind === "name" ? this.target.name : (await this.native()).name;
118
+ const reader = await this.readerWith({ kind: "group" })
119
+ .start(filteredStart(resolved.startFrom))
120
+ .count(resolved.batchLength)
121
+ .maxExamined(resolved.batchLength)
122
+ .idleInterval(resolved.pollIntervalMs)
123
+ .build();
124
+ return new Consumer(this.transport, this.streamName, this.topicName, { kind: "group", name }, options, reader);
125
+ }
126
+ /**
127
+ * Pages selected by the group's policy with original offsets, an independent
128
+ * scan budget, and explicit acknowledgments. An unbound group returns every
129
+ * record without evaluating its payload.
130
+ */
131
+ reader() {
132
+ return this.readerWith({ kind: "group" });
133
+ }
134
+ /**
135
+ * The native Apache Iggy group consumer, for a runtime that owns its own
136
+ * delivery contract.
137
+ *
138
+ * @internal
139
+ */
140
+ async [INTERNAL_NATIVE_CONSUMER](options = {}) {
141
+ const name = this.target.kind === "name" ? this.target.name : (await this.native()).name;
142
+ await this.transport.joinConsumerGroup(this.streamName, this.topicName, name);
143
+ return new Consumer(this.transport, this.streamName, this.topicName, { kind: "group", name }, options);
144
+ }
145
+ /** @internal */
146
+ filters() {
147
+ const context = this.context;
148
+ if (context === undefined) {
149
+ throw new UnsupportedError("consumer group filters need a topic built from a Laser client");
150
+ }
151
+ return new Filters(context.transport, context.capabilities);
152
+ }
153
+ /** @internal */
154
+ remember(position) {
155
+ if (position === undefined)
156
+ return;
157
+ const known = this.configuredAt;
158
+ if (known?.partitionId !== position.partitionId ||
159
+ known.offset < position.offset ||
160
+ (position.operationId !== undefined && known.operationId !== position.operationId)) {
161
+ this.configuredAt = position;
162
+ }
163
+ }
164
+ // The names the catalog addresses the group by. A numeric handle reads them
165
+ // from the server.
166
+ /** @internal */
167
+ async groupRef() {
168
+ return {
169
+ stream: this.streamName,
170
+ topic: this.topicName,
171
+ group: this.target.kind === "name" ? this.target.name : (await this.native()).name
172
+ };
173
+ }
174
+ readerWith(filter) {
175
+ const context = this.context;
176
+ if (context === undefined) {
177
+ throw new UnsupportedError("a group reader needs a topic built from a Laser client");
178
+ }
179
+ return FilteredReaderBuilder.create(context.transport, context.capabilities, this.filters(), { stream: this.streamName, topic: this.topicName }, this.selector(), filter, this.configuredAt);
180
+ }
181
+ selector() {
182
+ return this.target.kind === "name"
183
+ ? { kind: "group", name: this.target.name }
184
+ : { kind: "group_id", id: this.target.id };
185
+ }
186
+ native() {
187
+ return nativeGroup(this.transport, { stream: this.streamName, topic: this.topicName }, this.target.kind === "name" ? this.target.name : Number(this.target.id));
188
+ }
189
+ async described(native) {
190
+ const capabilities = await this.context?.capabilities();
191
+ const filter = capabilities?.filters.catalog === true ? await this.filter().get() : undefined;
192
+ if (filter !== undefined)
193
+ requireSameGroup(native.identity, filter.identity);
194
+ return {
195
+ id: native.id,
196
+ name: native.name,
197
+ identity: native.identity,
198
+ ...(filter !== undefined ? { filter } : {})
199
+ };
200
+ }
201
+ }
202
+ /**
203
+ * A consumer group's filter policy. Build it with `ConsumerGroup.filter()`.
204
+ * Every verb needs a managed plane that serves the filter catalog.
205
+ */
206
+ export class GroupFilter {
207
+ group;
208
+ constructor(group) {
209
+ this.group = group;
210
+ }
211
+ /** @internal */
212
+ static create(group) {
213
+ return new GroupFilter(group);
214
+ }
215
+ /**
216
+ * Give the group `filter` as its policy. The definition is saved as the
217
+ * group's own filter and the group is bound to it in one catalog
218
+ * transaction. The same digest again keeps the binding. Another digest on a
219
+ * group that runs a policy throws with reason `conflict`: create a new group
220
+ * for another policy.
221
+ */
222
+ configure(filter) {
223
+ return this.configureAs(undefined, { kind: "definition", filter });
224
+ }
225
+ /** `configure` with a definition or one of the group's own revisions. */
226
+ configureWith(policy) {
227
+ return this.configureAs(undefined, policy);
228
+ }
229
+ /**
230
+ * `configureWith` under a caller-chosen operation id, so a caller that
231
+ * records the id first resumes the same configuration after a crash and
232
+ * reads its first outcome.
233
+ */
234
+ async configureAs(operationId, policy) {
235
+ const native = await this.group.native();
236
+ const configured = await this.group
237
+ .filters()
238
+ .configureGroup({ stream: this.group.streamName, topic: this.group.topicName, group: native.name }, policy, operationId, native.identity);
239
+ requireSameGroup(native.identity, configured.binding.identity);
240
+ this.group.remember(configured.catalogPosition);
241
+ return configured.binding;
242
+ }
243
+ /** The active policy, `undefined` for an unbound group. */
244
+ async get() {
245
+ // The catalog gate comes first, like Rust: without a plane the answer is
246
+ // `unsupported`, whatever the native group looks like.
247
+ await this.group.filters().requireCatalog();
248
+ const native = await this.group.native();
249
+ try {
250
+ const binding = await this.group.filters().binding({
251
+ stream: this.group.streamName,
252
+ topic: this.group.topicName,
253
+ group: native.name
254
+ });
255
+ requireSameGroup(native.identity, binding.identity);
256
+ return binding;
257
+ }
258
+ catch (error) {
259
+ if (error instanceof FilterExecutionError && error.reason === "not_found")
260
+ return undefined;
261
+ throw error;
262
+ }
263
+ }
264
+ /** One page of the group's own filter revisions, newest first. */
265
+ async revisions(options = {}) {
266
+ const active = await this.active();
267
+ return this.group.filters().revisions(active.filterId, options);
268
+ }
269
+ /**
270
+ * Draft a revision of the group's own filter. Readers keep running the
271
+ * active revision. `expectedRevision` must still be the latest.
272
+ */
273
+ async revise(expectedRevision, filter) {
274
+ const active = await this.active();
275
+ return this.group.filters().revise(active.filterId, expectedRevision, filter);
276
+ }
277
+ /**
278
+ * Pause or resume a revision of the group's own filter. A paused active
279
+ * revision refuses new reads, while records already delivered can still be
280
+ * acknowledged.
281
+ */
282
+ async setRevisionEnabled(revision, enabled) {
283
+ const active = await this.active();
284
+ await this.group.filters().setRevisionEnabled(active.filterId, revision, enabled);
285
+ }
286
+ /**
287
+ * Delete the group's own filter with every revision. A bound group is
288
+ * released first, so its consumers receive every record from their next
289
+ * poll. Nothing of the filter stays in the catalog. `false` when the group
290
+ * has no filter of its own.
291
+ */
292
+ async delete() {
293
+ await this.group.filters().requireCatalog();
294
+ const native = await this.group.native();
295
+ const name = groupFilterName(native.identity);
296
+ const filters = this.group.filters();
297
+ let beforeId;
298
+ for (;;) {
299
+ const page = await filters.list(name, { pageSize: GROUP_FILTER_LOOKUP_PAGE }, beforeId);
300
+ const own = page.items.find((summary) => summary.name === name);
301
+ if (own !== undefined) {
302
+ this.group.remember(await filters.dropFilter(own.id));
303
+ return true;
304
+ }
305
+ const next = page.items.at(-1)?.id;
306
+ if (next === undefined)
307
+ return false;
308
+ if (beforeId !== undefined && next >= beforeId) {
309
+ throw new FilterExecutionError("the catalog lookup cursor did not advance", {
310
+ code: { kind: "known", name: "Unavailable" },
311
+ reason: "catalog_unavailable",
312
+ message: "the catalog lookup cursor did not advance"
313
+ });
314
+ }
315
+ if (page.items.length >= page.total)
316
+ return false;
317
+ beforeId = next;
318
+ }
319
+ }
320
+ /**
321
+ * Release the group's policy. Its readers then receive every record. A
322
+ * released group may only be configured with the digest it ran.
323
+ */
324
+ async release() {
325
+ const released = await this.group.filters().releaseGroup(await this.active());
326
+ this.group.remember(released.catalogPosition);
327
+ return released.binding;
328
+ }
329
+ /**
330
+ * Preview the active policy over the stored records of one partition. A
331
+ * preview joins no group, stores no offset, and changes no consumer state.
332
+ */
333
+ async preview(partitionId, options = {}) {
334
+ const active = await this.active();
335
+ return this.group
336
+ .filters()
337
+ .preview(this.group.streamName, this.group.topicName, partitionId, { kind: "revision", filterId: active.filterId, revision: active.revision }, options);
338
+ }
339
+ /**
340
+ * Evaluate the active policy against one supplied record and explain the
341
+ * verdict. Nothing is read from a stream and nothing is stored.
342
+ */
343
+ async test(payload, headers = []) {
344
+ const active = await this.active();
345
+ return this.group
346
+ .filters()
347
+ .test({ kind: "revision", filterId: active.filterId, revision: active.revision }, payload, headers);
348
+ }
349
+ async active() {
350
+ const binding = await this.get();
351
+ if (binding === undefined) {
352
+ throw new FilterExecutionError("not_found: the consumer group has no filter policy", {
353
+ code: { kind: "known", name: "NotFound" },
354
+ reason: "not_found",
355
+ message: "the consumer group has no filter policy"
356
+ });
357
+ }
358
+ return binding;
359
+ }
360
+ }
361
+ // The catalog names a group's own filter by the ids of the group incarnation
362
+ // it was configured for. The name is unique, so the first page holds it.
363
+ const GROUP_FILTER_LOOKUP_PAGE = 8;
364
+ function groupFilterName(identity) {
365
+ return `group:${String(identity.streamId)}:${identity.streamCreatedAtMicros.toString()}:${String(identity.topicId)}:${identity.topicCreatedAtMicros.toString()}:${identity.groupId.toString()}`;
366
+ }
367
+ function requireSameGroup(expected, actual) {
368
+ if (expected.streamId !== actual.streamId ||
369
+ expected.streamCreatedAtMicros !== actual.streamCreatedAtMicros ||
370
+ expected.topicId !== actual.topicId ||
371
+ expected.topicCreatedAtMicros !== actual.topicCreatedAtMicros ||
372
+ expected.groupId !== actual.groupId) {
373
+ throw new FilterExecutionError("the group incarnation changed while its policy was resolved", {
374
+ code: { kind: "known", name: "StaleGeneration" },
375
+ reason: "source_changed",
376
+ message: "the group incarnation changed while its policy was resolved, refresh its identity"
377
+ });
378
+ }
379
+ }
380
+ /**
381
+ * Whether a group consumer reads through the group reader. A server that
382
+ * advertises group-aware reads does. A server that serves consumer filters
383
+ * without them must be upgraded, because its groups may be bound and a native
384
+ * poll would read past their policies. A probe that established nothing is
385
+ * not a server without filters. Only a server whose announcement, or refusal
386
+ * to announce, positively lacks filters reads natively.
387
+ */
388
+ export function policyAware(capabilities) {
389
+ if (capabilities.filters.groupPolicyReads)
390
+ return true;
391
+ if (capabilities.filters.native) {
392
+ throw new UnsupportedError("this server serves consumer filters but not group-aware reads, upgrade it before consuming groups through the Laser SDK");
393
+ }
394
+ if (capabilities.hello === "failed" || capabilities.hello === "unknown") {
395
+ throw new TransportError("the managed probe that decides whether this server resolves consumer group policies did not answer, reconnect and build the consumer again", true);
396
+ }
397
+ return false;
398
+ }
399
+ function filteredStart(start) {
400
+ switch (start.kind) {
401
+ case "first":
402
+ case "last":
403
+ case "next":
404
+ return { kind: start.kind };
405
+ case "offset":
406
+ return { kind: "offset", offset: start.value };
407
+ case "timestamp":
408
+ return { kind: "timestamp", micros: start.value };
409
+ }
410
+ }
411
+ //# sourceMappingURL=consumer-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-group.js","sourceRoot":"","sources":["../../src/stream/consumer-group.ts"],"names":[],"mappings":"AACA,OAAO,EACL,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gB,CACxB,yHAAyH,CAC1H,CAAA;IACH,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,KAAK,QAAQ,IAAI,YAAY,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACxE,MAAM,IAAI,cAAc,CACtB,4IAA4I,EAC5I,IAAI,CACL,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,aAAa,CAAC,KAAsB;IAC3C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAA;QAC7B,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;QAChD,KAAK,WAAW;YACd,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;IACrD,CAAC;AACH,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { ConsumerTarget, IggyHeaderValue, LaserTransport } from "../iggy/apache-iggy.js";
2
+ import type { FilteredReader } from "../managed/filters.js";
2
3
  import type { PollingStrategy } from "./polling-strategy.js";
3
4
  export interface ConsumedMessage {
4
5
  readonly payload: Uint8Array;
@@ -13,21 +14,40 @@ export interface ConsumerOptions {
13
14
  readonly startFrom?: PollingStrategy;
14
15
  readonly pollIntervalMs?: number;
15
16
  }
17
+ /** A consumer's options with every default applied and validated. */
18
+ export interface ResolvedConsumerOptions {
19
+ readonly batchLength: number;
20
+ readonly autoCommit: boolean;
21
+ readonly startFrom: PollingStrategy;
22
+ readonly pollIntervalMs: number;
23
+ }
24
+ /** Apply the defaults and reject values no consumer can run with. */
25
+ export declare function resolveConsumerOptions(options: ConsumerOptions, anonymous: boolean): ResolvedConsumerOptions;
16
26
  /**
17
- * Polls one partition or consumer group until shutdown. A purge restarts the
18
- * partition at offset 0 without telling an open reader, which can keep its old
19
- * position and skip the replacement records, so rebuild it after a purge.
27
+ * Polls one partition or consumer group until shutdown. A group consumer on a
28
+ * server that resolves group policies reads through the group reader: the
29
+ * server runs the group's filter, or none, and commits go through the group's
30
+ * fenced acknowledgments. `batchLength` then also bounds the source records
31
+ * one partition poll examines. A purge restarts the partition at offset 0
32
+ * without telling an open reader, which can keep its old position and skip
33
+ * the replacement records, so rebuild it after a purge.
20
34
  */
21
35
  export declare class Consumer implements AsyncIterable<ConsumedMessage>, AsyncDisposable {
22
36
  private readonly transport;
23
37
  private readonly streamName;
24
38
  private readonly topicName;
25
39
  private readonly target;
40
+ private readonly reader?;
26
41
  private readonly batchLength;
27
42
  private readonly autoCommit;
28
43
  private readonly startFrom;
29
44
  private readonly pollIntervalMs;
30
45
  private buffer;
46
+ private readonly records;
47
+ private readonly delivered;
48
+ private handledSincePoll;
49
+ private lastDelivery;
50
+ private moreScanned;
31
51
  private readonly consumedOffsets;
32
52
  private readonly explicitOffsets;
33
53
  private readonly nextOffsets;
@@ -37,7 +57,7 @@ export declare class Consumer implements AsyncIterable<ConsumedMessage>, AsyncDi
37
57
  private readonly gainedPartitions;
38
58
  private started;
39
59
  private shuttingDown;
40
- constructor(transport: LaserTransport, streamName: string, topicName: string, target: ConsumerTarget, options?: ConsumerOptions);
60
+ constructor(transport: LaserTransport, streamName: string, topicName: string, target: ConsumerTarget, options?: ConsumerOptions, reader?: FilteredReader | undefined);
41
61
  nextWithin(timeoutMs: number, options?: {
42
62
  readonly signal?: AbortSignal;
43
63
  }): Promise<ConsumedMessage | null>;
@@ -45,16 +65,29 @@ export declare class Consumer implements AsyncIterable<ConsumedMessage>, AsyncDi
45
65
  stream(options?: {
46
66
  readonly signal?: AbortSignal;
47
67
  }): AsyncIterable<ConsumedMessage>;
68
+ /**
69
+ * Store a handled message's offset on the server. A group consumer on a
70
+ * server that resolves group policies stores the contiguous prefix of the
71
+ * partition through this message, and needs the message object it delivered.
72
+ */
48
73
  commit(message: ConsumedMessage): Promise<void>;
49
74
  lastConsumedOffset(partitionId: number): bigint | undefined;
50
75
  storedOffset(partitionId: number): Promise<{
51
76
  readonly storedOffset: bigint;
52
77
  readonly currentOffset: bigint;
53
78
  } | undefined>;
54
- /** Ends iteration and leaves the consumer group when present. */
79
+ /**
80
+ * Ends iteration and leaves the consumer group when present. An
81
+ * auto-committing consumer stores the delivered prefix first.
82
+ */
55
83
  shutdown(): Promise<void>;
56
84
  /** Delegates async disposal to `shutdown()`. */
57
85
  [Symbol.asyncDispose](): Promise<void>;
86
+ private take;
87
+ private pending;
88
+ private stopped;
89
+ private handledPrevious;
90
+ private fillFromGroup;
58
91
  private fillBuffer;
59
92
  }
60
93
  //# sourceMappingURL=consumer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/stream/consumer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,cAAc,EAEf,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CACvD;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAA;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CACjC;AA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