@eventferry/kafka 3.0.0 → 3.2.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.md +249 -0
- package/dist/index.cjs +292 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +331 -13
- package/dist/index.d.ts +331 -13
- package/dist/index.js +287 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublishableMessage, PublishResult, PublishErrorKind, Publisher } from '@eventferry/core';
|
|
1
|
+
import { PublishableMessage, PublishResult, Logger, PublishErrorKind, Publisher } from '@eventferry/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Low-level driver contract. Each concrete driver (kafkajs, confluent)
|
|
@@ -20,17 +20,108 @@ interface KafkaDriver {
|
|
|
20
20
|
*/
|
|
21
21
|
readonly transactional: boolean;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* TLS configuration for client connections. Pass a full {@link TlsConfig}
|
|
25
|
+
* when the cluster requires CA pinning, mutual TLS (client cert + key), or a
|
|
26
|
+
* specific SNI host. Plain `ssl: true` keeps the previous behavior (one-way
|
|
27
|
+
* TLS using the driver's default trust store).
|
|
28
|
+
*
|
|
29
|
+
* `rejectUnauthorized` is intentionally NOT a knob here — TLS verification is
|
|
30
|
+
* non-negotiable. Dev clusters with self-signed certs pass their CA via `ca`.
|
|
31
|
+
*/
|
|
32
|
+
interface TlsConfig {
|
|
33
|
+
/** PEM-encoded CA bundle. Buffers and strings both accepted. */
|
|
34
|
+
ca?: string | Buffer | Array<string | Buffer>;
|
|
35
|
+
/** PEM-encoded client certificate (required for mTLS). */
|
|
36
|
+
cert?: string | Buffer;
|
|
37
|
+
/** PEM-encoded private key for the client certificate (required for mTLS). */
|
|
38
|
+
key?: string | Buffer;
|
|
39
|
+
/** Passphrase for an encrypted private key. */
|
|
40
|
+
passphrase?: string;
|
|
41
|
+
/** SNI host. Useful when broker address doesn't match the cert SAN. */
|
|
42
|
+
servername?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Username + password SASL: PLAIN and SCRAM-SHA-256/512. The conventional
|
|
46
|
+
* "API key + secret" shape used by Confluent Cloud, Aiven, on-prem SCRAM.
|
|
47
|
+
*/
|
|
48
|
+
interface SaslPasswordConfig {
|
|
49
|
+
mechanism: "plain" | "scram-sha-256" | "scram-sha-512";
|
|
50
|
+
username: string;
|
|
51
|
+
password: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Token returned by an OAUTHBEARER provider.
|
|
55
|
+
*
|
|
56
|
+
* Driver asymmetry (verified against `kafkajs/types/index.d.ts` and
|
|
57
|
+
* `@confluentinc/kafka-javascript/types/kafkajs.d.ts`):
|
|
58
|
+
*
|
|
59
|
+
* - `kafkajs` reads only `value`. Other fields are silently ignored.
|
|
60
|
+
* - `@confluentinc/kafka-javascript` REQUIRES `value` + `principal` + `lifetime`
|
|
61
|
+
* and accepts an optional `extensions` map. Passing only `{ value }` throws.
|
|
62
|
+
*
|
|
63
|
+
* Cross-driver portable providers MUST populate all four. eventferry treats
|
|
64
|
+
* `principal` / `lifetime` / `extensions` as optional in the type to support
|
|
65
|
+
* kafkajs-only setups; supplying them is a no-op there.
|
|
66
|
+
*/
|
|
67
|
+
interface OauthBearerToken {
|
|
68
|
+
/** The bearer token string (JWT, opaque, …). */
|
|
69
|
+
value: string;
|
|
70
|
+
/** Principal name. REQUIRED on the confluent driver. */
|
|
71
|
+
principal?: string;
|
|
72
|
+
/** Lifetime in MILLISECONDS. REQUIRED on the confluent driver. */
|
|
73
|
+
lifetime?: number;
|
|
74
|
+
/** SASL extensions to send alongside the token (e.g. for OIDC scopes). */
|
|
75
|
+
extensions?: Record<string, string>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* SASL/OAUTHBEARER: bring-your-own token provider. The function is invoked
|
|
79
|
+
* by the underlying client on demand (NOT on a fixed timer); cache the
|
|
80
|
+
* token in your provider if you want to amortise issuance cost.
|
|
81
|
+
*
|
|
82
|
+
* Required for Azure Event Hubs, Confluent Cloud with OAuth/SSO, and any
|
|
83
|
+
* OIDC-fronted Kafka. For AWS MSK IAM, wrap the AWS SigV4 signer in this
|
|
84
|
+
* callback.
|
|
85
|
+
*/
|
|
86
|
+
interface SaslOauthbearerConfig {
|
|
87
|
+
mechanism: "oauthbearer";
|
|
88
|
+
oauthBearerProvider: () => Promise<OauthBearerToken>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Discriminated union over the SASL mechanisms eventferry supports today.
|
|
92
|
+
* Add new mechanisms by extending this union and mapping them in each driver.
|
|
93
|
+
*/
|
|
94
|
+
type SaslConfig = SaslPasswordConfig | SaslOauthbearerConfig;
|
|
23
95
|
/** Shared connection config accepted by both drivers. */
|
|
24
96
|
interface KafkaConnectionConfig {
|
|
25
97
|
brokers: string[];
|
|
26
98
|
clientId?: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
99
|
+
/**
|
|
100
|
+
* TLS configuration. `true` enables one-way TLS using the driver's default
|
|
101
|
+
* trust store; a {@link TlsConfig} object lets you supply a custom CA,
|
|
102
|
+
* client cert (for mTLS), and SNI host.
|
|
103
|
+
*/
|
|
104
|
+
ssl?: boolean | TlsConfig;
|
|
105
|
+
sasl?: SaslConfig;
|
|
33
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Choice of partitioner. Only honored by the kafkajs driver — the confluent
|
|
109
|
+
* driver uses librdkafka's `consistent_random` (key-aware sticky) and
|
|
110
|
+
* partitioner override is out of scope for this release.
|
|
111
|
+
*
|
|
112
|
+
* - `"java-compatible"` (recommended for greenfield): kafkajs's
|
|
113
|
+
* `Partitioners.JavaCompatiblePartitioner`. Matches the Java client's
|
|
114
|
+
* murmur2-based hash so producers across language boundaries land on the
|
|
115
|
+
* same partition for the same key.
|
|
116
|
+
* - `"legacy"`: kafkajs's pre-v2 partitioner. Use when migrating an existing
|
|
117
|
+
* topic where hash continuity matters.
|
|
118
|
+
* - `"default"`: kafkajs's current default. Equivalent to legacy in v2 but
|
|
119
|
+
* may change with major kafkajs releases.
|
|
120
|
+
*
|
|
121
|
+
* Setting this also silences the noisy `KafkaJSPartitionerNotSpecified`
|
|
122
|
+
* warning kafkajs emits when no partitioner choice is made explicitly.
|
|
123
|
+
*/
|
|
124
|
+
type KafkaJsPartitionerChoice = "default" | "legacy" | "java-compatible";
|
|
34
125
|
interface ProducerBehaviorConfig {
|
|
35
126
|
/** Enable idempotent producer (dedup + ordering). Default true. */
|
|
36
127
|
idempotent?: boolean;
|
|
@@ -39,12 +130,75 @@ interface ProducerBehaviorConfig {
|
|
|
39
130
|
* Requires a stable transactionalId. Default false.
|
|
40
131
|
*/
|
|
41
132
|
transactional?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Required when `transactional=true`. Must be stable per producer instance
|
|
135
|
+
* — two producers sharing the same id race for the broker-side epoch and
|
|
136
|
+
* fence each other.
|
|
137
|
+
*
|
|
138
|
+
* Accepts a string OR a thunk that resolves the id at connect time. The
|
|
139
|
+
* callable form lets you derive the id from runtime context that's not
|
|
140
|
+
* known at construction (pod name, AZ + replica index, k8s ordinal):
|
|
141
|
+
*
|
|
142
|
+
* transactionalId: () => `${process.env.POD_NAME}-${replicaIndex()}`,
|
|
143
|
+
*
|
|
144
|
+
* For multi-instance EOS, the derived id MUST be stable across a single
|
|
145
|
+
* instance's restarts but UNIQUE across instances.
|
|
146
|
+
*/
|
|
147
|
+
transactionalId?: string | (() => string | Promise<string>);
|
|
44
148
|
/** acks: -1/"all" (default), 0, or 1. */
|
|
45
149
|
acks?: number;
|
|
46
150
|
/** Compression codec. Driver maps to its native enum. */
|
|
47
151
|
compression?: "none" | "gzip" | "snappy" | "lz4" | "zstd";
|
|
152
|
+
/**
|
|
153
|
+
* (confluent only) How long the producer waits to accumulate records before
|
|
154
|
+
* flushing a partition batch. Default 0 (ship-immediately). Increase to
|
|
155
|
+
* 10–50ms for higher throughput at the cost of latency.
|
|
156
|
+
*/
|
|
157
|
+
lingerMs?: number;
|
|
158
|
+
/** (confluent only) Maximum bytes per partition batch before forced flush. */
|
|
159
|
+
batchSize?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Max concurrent unacknowledged producer requests. MUST be ≤5 when
|
|
162
|
+
* `idempotent: true`. Higher = throughput; lower = stricter ordering on
|
|
163
|
+
* non-idempotent producers (no other path preserves order on retry).
|
|
164
|
+
*/
|
|
165
|
+
maxInFlightRequests?: number;
|
|
166
|
+
/** Per-request broker-ack timeout. Default 30 s. */
|
|
167
|
+
requestTimeoutMs?: number;
|
|
168
|
+
/**
|
|
169
|
+
* (confluent only) End-to-end timeout for a record from produce() call to
|
|
170
|
+
* terminal success / failure (includes retries). Defaults to 120 s.
|
|
171
|
+
* If this exceeds the relay's `claimTimeoutMs`, the reaper may double-
|
|
172
|
+
* publish a slow record — set both coherently.
|
|
173
|
+
*/
|
|
174
|
+
deliveryTimeoutMs?: number;
|
|
175
|
+
/**
|
|
176
|
+
* (confluent only) Max bytes of a single record (after compression).
|
|
177
|
+
* MUST be ≤ broker's `message.max.bytes`. Defaults to 1 MB.
|
|
178
|
+
*/
|
|
179
|
+
maxRequestSize?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Broker-side ceiling on how long a transaction can stay open before
|
|
182
|
+
* auto-abort. Maps to `transaction.timeout.ms`. Default 60 s; capped by
|
|
183
|
+
* the broker's `transaction.max.timeout.ms`.
|
|
184
|
+
*/
|
|
185
|
+
transactionTimeoutMs?: number;
|
|
186
|
+
/**
|
|
187
|
+
* (kafkajs only) Choice of partitioner. See
|
|
188
|
+
* {@link KafkaJsPartitionerChoice} for the options. Setting any value
|
|
189
|
+
* silences kafkajs's `KafkaJSPartitionerNotSpecified` warning.
|
|
190
|
+
*/
|
|
191
|
+
partitioner?: KafkaJsPartitionerChoice;
|
|
192
|
+
/**
|
|
193
|
+
* Callback fired when a transactional `sendBatch` triggers the abort
|
|
194
|
+
* path (e.g. mid-batch driver error, broker rejection). Used by the
|
|
195
|
+
* publisher to fan out the matching `KafkaPublisherHooks.onTransactionAbort`
|
|
196
|
+
* hook — but advanced users constructing a driver directly may also wire
|
|
197
|
+
* it themselves. Best-effort: the driver still proceeds to abort the
|
|
198
|
+
* underlying transaction and return per-record failures regardless of
|
|
199
|
+
* whether this callback throws.
|
|
200
|
+
*/
|
|
201
|
+
onTransactionAbort?: (error: Error) => void;
|
|
48
202
|
}
|
|
49
203
|
type DriverKind = "kafkajs" | "confluent";
|
|
50
204
|
|
|
@@ -60,6 +214,12 @@ interface KjsTransaction {
|
|
|
60
214
|
abort(): Promise<void>;
|
|
61
215
|
}
|
|
62
216
|
interface KafkaJsDriverOptions extends KafkaConnectionConfig, ProducerBehaviorConfig {
|
|
217
|
+
/**
|
|
218
|
+
* Optional logger for the driver's own diagnostics (e.g. warnings about
|
|
219
|
+
* unsupported tuning options). When absent the driver falls back to
|
|
220
|
+
* `console.warn` so existing users see the same output.
|
|
221
|
+
*/
|
|
222
|
+
logger?: Logger;
|
|
63
223
|
}
|
|
64
224
|
/**
|
|
65
225
|
* Driver backed by the pure-JS `kafkajs` client. Simple, zero native deps.
|
|
@@ -78,6 +238,8 @@ declare class KafkaJsDriver implements KafkaDriver {
|
|
|
78
238
|
disconnect(): Promise<void>;
|
|
79
239
|
sendBatch(messages: PublishableMessage[]): Promise<PublishResult[]>;
|
|
80
240
|
}
|
|
241
|
+
/** Internal — used by tests. Resets the dedup so warnings can be observed in isolation. */
|
|
242
|
+
declare function _resetKafkajsWarnDedup(): void;
|
|
81
243
|
|
|
82
244
|
/**
|
|
83
245
|
* Classify a kafkajs producer error into a {@link PublishErrorKind} so the
|
|
@@ -144,6 +306,132 @@ declare class ConfluentDriver implements KafkaDriver {
|
|
|
144
306
|
*/
|
|
145
307
|
declare function classifyConfluentError(err: unknown): PublishErrorKind;
|
|
146
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Translate eventferry's normalized `KafkaConnectionConfig` into the shape
|
|
311
|
+
* expected by `@confluentinc/kafka-javascript`'s `KafkaJS.Kafka` constructor.
|
|
312
|
+
*
|
|
313
|
+
* Returns an object with two parts:
|
|
314
|
+
* - `kafkaJS`: the kafkajs-compatible config layer (clientId, brokers, and
|
|
315
|
+
* simple ssl/sasl when no advanced TLS is needed).
|
|
316
|
+
* - top-level keys: librdkafka-style config (e.g. `ssl.ca.pem`,
|
|
317
|
+
* `security.protocol`) used when the user supplies a {@link TlsConfig}.
|
|
318
|
+
*
|
|
319
|
+
* Why a separate translator: the kafkajs-compat layer accepts the simple
|
|
320
|
+
* `ssl: true` boolean but the verified path for mTLS (CA + cert + key) is
|
|
321
|
+
* librdkafka's `ssl.*.pem` keys. The translator picks the right surface
|
|
322
|
+
* based on what the caller supplied. Buffer inputs are coerced to strings —
|
|
323
|
+
* librdkafka accepts PEM strings, NOT Buffers.
|
|
324
|
+
*/
|
|
325
|
+
interface ConfluentClientConfig {
|
|
326
|
+
kafkaJS: Record<string, unknown>;
|
|
327
|
+
librdkafka: Record<string, unknown>;
|
|
328
|
+
}
|
|
329
|
+
declare function buildConfluentClientConfig(opts: KafkaConnectionConfig & ProducerBehaviorConfig): ConfluentClientConfig;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Lifecycle hooks fired by `KafkaPublisher`. Every hook is optional. The
|
|
333
|
+
* publisher wraps each invocation in a try/catch and logs (via the
|
|
334
|
+
* configured logger) on failure — a misbehaving hook will NEVER break
|
|
335
|
+
* publishing.
|
|
336
|
+
*
|
|
337
|
+
* Typical wiring:
|
|
338
|
+
* - Custom observability stacks (Datadog APM, New Relic) → `onPublish`,
|
|
339
|
+
* `onError`, `onTransactionAbort`.
|
|
340
|
+
* - Connection-aware readiness probes → `onConnect` / `onDisconnect`.
|
|
341
|
+
* - Audit logs of every published record → `onPublish`.
|
|
342
|
+
*/
|
|
343
|
+
interface KafkaPublisherHooks {
|
|
344
|
+
/** Fires after the underlying client successfully connects. */
|
|
345
|
+
onConnect?(): void | Promise<void>;
|
|
346
|
+
/** Fires after the underlying client disconnects (clean shutdown). */
|
|
347
|
+
onDisconnect?(): void | Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Fires once per record after a publish attempt — both successes and
|
|
350
|
+
* failures. The `result.ok` flag distinguishes them.
|
|
351
|
+
*/
|
|
352
|
+
onPublish?(result: PublishResult, message: PublishableMessage): void | Promise<void>;
|
|
353
|
+
/**
|
|
354
|
+
* Fires for any error surfaced from the publish path — driver-thrown
|
|
355
|
+
* errors, transaction abort errors, etc. `message` is set when the error
|
|
356
|
+
* is per-record; absent for batch-level errors (e.g. connect failure).
|
|
357
|
+
*/
|
|
358
|
+
onError?(error: Error, message?: PublishableMessage): void | Promise<void>;
|
|
359
|
+
/**
|
|
360
|
+
* Fires when a transactional sendBatch's inner abort path is taken.
|
|
361
|
+
* Useful for observability dashboards that track EOS failure rates.
|
|
362
|
+
*/
|
|
363
|
+
onTransactionAbort?(error: Error): void | Promise<void>;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Invoke a hook safely. Never throws back into the caller — logs the hook's
|
|
367
|
+
* failure via the configured logger (or no-op when logger is absent).
|
|
368
|
+
*/
|
|
369
|
+
declare function safeHook(logger: Logger | undefined, hookName: keyof KafkaPublisherHooks, invoke: () => void | Promise<void> | undefined): Promise<void>;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Tracing surface for the publisher.
|
|
373
|
+
*
|
|
374
|
+
* eventferry deliberately does not depend on `@opentelemetry/api` — instead
|
|
375
|
+
* users wire a thin adapter over their tracing system (OpenTelemetry,
|
|
376
|
+
* Datadog, internal, …). This file defines the minimal contract; an
|
|
377
|
+
* OpenTelemetry adapter is ~10 lines (see the README).
|
|
378
|
+
*
|
|
379
|
+
* The contract follows the **current stable** OpenTelemetry messaging
|
|
380
|
+
* semantic conventions
|
|
381
|
+
* ({@link https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/kafka.md spec}):
|
|
382
|
+
*
|
|
383
|
+
* - Span name: `"{topic} publish"`
|
|
384
|
+
* - `SpanKind.PRODUCER`
|
|
385
|
+
* - Required attributes: `messaging.system=kafka`,
|
|
386
|
+
* `messaging.operation.type=publish`, `messaging.destination.name=<topic>`
|
|
387
|
+
* - Recommended: `messaging.batch.message_count`, `messaging.kafka.partition`,
|
|
388
|
+
* `server.address`, `server.port`
|
|
389
|
+
* - One span per batch (NOT per message — per-message spans cause
|
|
390
|
+
* cardinality explosion and the spec actively warns against this)
|
|
391
|
+
*/
|
|
392
|
+
/** Attribute values the spec allows. */
|
|
393
|
+
type SpanAttributeValue = string | number | boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Minimal span surface the publisher needs. Implementations wrap a
|
|
396
|
+
* tracing-system-specific span; methods MUST never throw out of the
|
|
397
|
+
* publisher's hot path (wrap your own SDK calls in try/catch).
|
|
398
|
+
*/
|
|
399
|
+
interface SpanLike {
|
|
400
|
+
setAttribute(key: string, value: SpanAttributeValue): void;
|
|
401
|
+
setAttributes(attrs: Record<string, SpanAttributeValue>): void;
|
|
402
|
+
/** OK on success; ERROR on failure. The `message` is the error message. */
|
|
403
|
+
setStatus(status: {
|
|
404
|
+
code: "ok" | "error";
|
|
405
|
+
message?: string;
|
|
406
|
+
}): void;
|
|
407
|
+
/** Attach an exception to the span (OpenTelemetry `recordException`). */
|
|
408
|
+
recordException(error: Error): void;
|
|
409
|
+
end(): void;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Factory the publisher calls once per `sendBatch` to start a span.
|
|
413
|
+
* Implementations MUST set `SpanKind.PRODUCER` and the messaging semconv
|
|
414
|
+
* attributes on the returned span before returning it.
|
|
415
|
+
*/
|
|
416
|
+
interface KafkaTracer {
|
|
417
|
+
/**
|
|
418
|
+
* Start a publish span.
|
|
419
|
+
* @param name Recommended format: `"{topic} publish"`.
|
|
420
|
+
* @param attributes Initial attributes (the publisher supplies the messaging
|
|
421
|
+
* semconv set: system, destination.name, operation.type,
|
|
422
|
+
* batch.message_count, plus optional kafka.partition and
|
|
423
|
+
* server.address/port).
|
|
424
|
+
*/
|
|
425
|
+
startPublishSpan(name: string, attributes: Record<string, SpanAttributeValue>): SpanLike;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* No-op tracer. Used when the user does not configure one. Cheap allocation
|
|
429
|
+
* — never touches I/O.
|
|
430
|
+
*/
|
|
431
|
+
declare class NoopKafkaTracer implements KafkaTracer {
|
|
432
|
+
startPublishSpan(): SpanLike;
|
|
433
|
+
}
|
|
434
|
+
|
|
147
435
|
interface KafkaPublisherOptions extends KafkaConnectionConfig, ProducerBehaviorConfig {
|
|
148
436
|
/** Which underlying client to use. Default "kafkajs". */
|
|
149
437
|
driver?: DriverKind;
|
|
@@ -152,14 +440,35 @@ interface KafkaPublisherOptions extends KafkaConnectionConfig, ProducerBehaviorC
|
|
|
152
440
|
* Useful for testing or unsupported clients.
|
|
153
441
|
*/
|
|
154
442
|
customDriver?: KafkaDriver;
|
|
443
|
+
/**
|
|
444
|
+
* Optional structured logger. When set, the publisher routes its own
|
|
445
|
+
* diagnostics (driver warnings, hook failures) through it. When omitted,
|
|
446
|
+
* the publisher is silent — only the underlying drivers may still log.
|
|
447
|
+
*/
|
|
448
|
+
logger?: Logger;
|
|
449
|
+
/**
|
|
450
|
+
* Optional lifecycle hooks. Every hook is invoked safely (try/catch +
|
|
451
|
+
* logged via `logger`) and a misbehaving hook will never break publishing.
|
|
452
|
+
*/
|
|
453
|
+
hooks?: KafkaPublisherHooks;
|
|
454
|
+
/**
|
|
455
|
+
* Optional tracer. When set, `publish()` wraps each batch in a span that
|
|
456
|
+
* follows the current stable OpenTelemetry messaging semantic conventions.
|
|
457
|
+
* Use a thin adapter over your tracing SDK (see {@link KafkaTracer}).
|
|
458
|
+
*/
|
|
459
|
+
tracer?: KafkaTracer;
|
|
155
460
|
}
|
|
156
461
|
/**
|
|
157
|
-
* The Publisher the Relay talks to. Wraps a pluggable KafkaDriver and
|
|
158
|
-
*
|
|
159
|
-
* (Redpanda is Kafka-API
|
|
462
|
+
* The Publisher the Relay talks to. Wraps a pluggable KafkaDriver and adds
|
|
463
|
+
* dead-letter routing, observability hooks, and OpenTelemetry-shaped publish
|
|
464
|
+
* spans. Works against Kafka and Redpanda identically (Redpanda is Kafka-API
|
|
465
|
+
* compatible).
|
|
160
466
|
*/
|
|
161
467
|
declare class KafkaPublisher implements Publisher {
|
|
162
468
|
private readonly driver;
|
|
469
|
+
private readonly logger;
|
|
470
|
+
private readonly hooks;
|
|
471
|
+
private readonly tracer;
|
|
163
472
|
constructor(opts: KafkaPublisherOptions);
|
|
164
473
|
connect(): Promise<void>;
|
|
165
474
|
disconnect(): Promise<void>;
|
|
@@ -171,6 +480,15 @@ declare class KafkaPublisher implements Publisher {
|
|
|
171
480
|
publishToDlq(message: PublishableMessage, error: Error): Promise<void>;
|
|
172
481
|
/** Whether the configured driver provides atomic (EOS) batch sends. */
|
|
173
482
|
get transactional(): boolean;
|
|
483
|
+
/**
|
|
484
|
+
* Start a span for the batch following the OTel messaging conventions.
|
|
485
|
+
*
|
|
486
|
+
* Multi-topic batches: per the OTel spec, the span name uses the
|
|
487
|
+
* destination — we pick the FIRST topic in the batch and document the
|
|
488
|
+
* limitation. Callers that publish heterogeneous batches and care about
|
|
489
|
+
* per-topic spans should split their batches upstream.
|
|
490
|
+
*/
|
|
491
|
+
private startBatchSpan;
|
|
174
492
|
}
|
|
175
493
|
|
|
176
|
-
export { ConfluentDriver, type ConfluentDriverOptions, type DriverKind, type KafkaConnectionConfig, type KafkaDriver, KafkaJsDriver, type KafkaJsDriverOptions, KafkaPublisher, type KafkaPublisherOptions, type ProducerBehaviorConfig, classifyConfluentError, classifyKafkajsError };
|
|
494
|
+
export { type ConfluentClientConfig, ConfluentDriver, type ConfluentDriverOptions, type DriverKind, type KafkaConnectionConfig, type KafkaDriver, KafkaJsDriver, type KafkaJsDriverOptions, type KafkaJsPartitionerChoice, KafkaPublisher, type KafkaPublisherHooks, type KafkaPublisherOptions, type KafkaTracer, NoopKafkaTracer, type OauthBearerToken, type ProducerBehaviorConfig, type SaslConfig, type SaslOauthbearerConfig, type SaslPasswordConfig, type SpanAttributeValue, type SpanLike, type TlsConfig, _resetKafkajsWarnDedup, buildConfluentClientConfig, classifyConfluentError, classifyKafkajsError, safeHook };
|