@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.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/kafkajs-classifier.ts","../src/kafkajs-driver.ts","../src/confluent-classifier.ts","../src/confluent-driver.ts","../src/publisher.ts"],"sourcesContent":["export * from \"./driver.js\";\nexport * from \"./kafkajs-driver.js\";\nexport * from \"./kafkajs-classifier.js\";\nexport * from \"./confluent-driver.js\";\nexport * from \"./confluent-classifier.js\";\nexport * from \"./publisher.js\";\n","import type { PublishErrorKind } from \"@eventferry/core\";\n\n/**\n * Classify a kafkajs producer error into a {@link PublishErrorKind} so the\n * core relay can decide whether to retry, short-circuit to the DLQ, or pause\n * polling.\n *\n * Mapping verified against `kafkajs/src/errors.js` (v2.x). Protocol error\n * codes match the Kafka Protocol error-code registry. Library-specific\n * subclasses (`KafkaJSRequestTimeoutError`, `KafkaJSConnectionError`,\n * `KafkaJSNonRetriableError`) are matched by the `name` property kafkajs\n * sets on its Error subclasses.\n *\n * Unknown errors fall back to `\"retriable\"` — the safe bias. At worst we\n * retry an error that should have been skipped; in practice we'd rather\n * over-retry than mis-classify a transient blip as terminal.\n */\nexport function classifyKafkajsError(err: unknown): PublishErrorKind {\n if (!err || typeof err !== \"object\") return \"retriable\";\n const e = err as { name?: string; type?: string; code?: number };\n\n // Class-based first — these don't carry a protocol error code.\n if (e.name === \"KafkaJSConnectionError\") return \"retriable\";\n if (e.name === \"KafkaJSRequestTimeoutError\") return \"retriable\";\n if (e.name === \"KafkaJSNonRetriableError\") return \"fatal\";\n\n // Protocol error type (string) — kafkajs's KafkaJSProtocolError exposes\n // both `type` (uppercase string) and `code` (number). Use `type` first\n // for readability and fall back to `code` for codes that lack a stable\n // string label.\n const type = typeof e.type === \"string\" ? e.type : undefined;\n if (type) {\n if (RETRIABLE_TYPES.has(type)) return \"retriable\";\n if (POISON_TYPES.has(type)) return \"poison\";\n if (FATAL_TYPES.has(type)) return \"fatal\";\n }\n\n if (typeof e.code === \"number\") {\n const k = CODE_TO_KIND.get(e.code);\n if (k) return k;\n }\n\n return \"retriable\";\n}\n\nconst RETRIABLE_TYPES = new Set<string>([\n \"NOT_LEADER_FOR_PARTITION\",\n \"LEADER_NOT_AVAILABLE\",\n \"UNKNOWN_TOPIC_OR_PARTITION\",\n \"NETWORK_EXCEPTION\",\n \"REQUEST_TIMED_OUT\",\n \"REPLICA_NOT_AVAILABLE\",\n \"NOT_ENOUGH_REPLICAS\",\n \"NOT_ENOUGH_REPLICAS_AFTER_APPEND\",\n \"FENCED_LEADER_EPOCH\",\n \"UNKNOWN_LEADER_EPOCH\",\n \"BROKER_NOT_AVAILABLE\",\n \"COORDINATOR_LOAD_IN_PROGRESS\",\n \"COORDINATOR_NOT_AVAILABLE\",\n]);\n\nconst POISON_TYPES = new Set<string>([\n \"CORRUPT_MESSAGE\",\n \"MESSAGE_TOO_LARGE\",\n \"INVALID_RECORD\",\n \"UNSUPPORTED_COMPRESSION_TYPE\",\n \"INVALID_REQUIRED_ACKS\",\n \"INVALID_PARTITIONS\",\n]);\n\nconst FATAL_TYPES = new Set<string>([\n \"INVALID_PRODUCER_EPOCH\",\n \"PRODUCER_FENCED\",\n \"TOPIC_AUTHORIZATION_FAILED\",\n \"CLUSTER_AUTHORIZATION_FAILED\",\n \"TRANSACTIONAL_ID_AUTHORIZATION_FAILED\",\n \"SASL_AUTHENTICATION_FAILED\",\n \"INVALID_TRANSACTION_STATE\",\n \"UNSUPPORTED_VERSION\",\n]);\n\n/** Numeric fallback for clusters that only return the wire code. */\nconst CODE_TO_KIND: ReadonlyMap<number, PublishErrorKind> = new Map([\n [2, \"poison\"], // CORRUPT_MESSAGE\n [3, \"retriable\"], // UNKNOWN_TOPIC_OR_PARTITION\n [5, \"retriable\"], // LEADER_NOT_AVAILABLE\n [6, \"retriable\"], // NOT_LEADER_FOR_PARTITION\n [7, \"retriable\"], // REQUEST_TIMED_OUT\n [9, \"retriable\"], // REPLICA_NOT_AVAILABLE\n [10, \"poison\"], // MESSAGE_TOO_LARGE\n [13, \"retriable\"], // NETWORK_EXCEPTION\n [19, \"retriable\"], // NOT_ENOUGH_REPLICAS\n [29, \"fatal\"], // TOPIC_AUTHORIZATION_FAILED\n [31, \"fatal\"], // CLUSTER_AUTHORIZATION_FAILED\n [47, \"fatal\"], // INVALID_PRODUCER_EPOCH\n [58, \"fatal\"], // SASL_AUTHENTICATION_FAILED\n [74, \"retriable\"], // FENCED_LEADER_EPOCH\n [76, \"poison\"], // UNSUPPORTED_COMPRESSION_TYPE\n [87, \"poison\"], // INVALID_RECORD\n]);\n","import type { PublishableMessage, PublishResult } from \"@eventferry/core\";\nimport { classifyKafkajsError } from \"./kafkajs-classifier.js\";\nimport type {\n KafkaConnectionConfig,\n KafkaDriver,\n ProducerBehaviorConfig,\n} from \"./driver.js\";\n\n// Loosely-typed structural references to the kafkajs API so this file\n// compiles without kafkajs installed (it's an optional peer dep).\ninterface KjsProducer {\n connect(): Promise<void>;\n disconnect(): Promise<void>;\n // kafkajs: sendBatch takes { topicMessages }, send takes a single { topic, messages }.\n sendBatch(args: unknown): Promise<unknown>;\n transaction(): Promise<KjsTransaction>;\n}\ninterface KjsTransaction {\n sendBatch(args: unknown): Promise<unknown>;\n commit(): Promise<void>;\n abort(): Promise<void>;\n}\ninterface KjsKafka {\n producer(args?: unknown): KjsProducer;\n}\n\nexport interface KafkaJsDriverOptions\n extends KafkaConnectionConfig,\n ProducerBehaviorConfig {}\n\n/**\n * Driver backed by the pure-JS `kafkajs` client. Simple, zero native deps.\n */\nexport class KafkaJsDriver implements KafkaDriver {\n readonly transactional: boolean;\n private producer: KjsProducer | null = null;\n private readonly opts: KafkaJsDriverOptions;\n\n constructor(opts: KafkaJsDriverOptions) {\n this.opts = opts;\n this.transactional = opts.transactional ?? false;\n if (this.transactional && !opts.transactionalId) {\n throw new Error(\n \"KafkaJsDriver: transactionalId is required when transactional=true\",\n );\n }\n }\n\n async connect(): Promise<void> {\n this.producer = await this.createProducer();\n await this.producer.connect();\n }\n\n /**\n * Construct the underlying kafkajs producer. Overridable as a test seam so\n * the send/transaction logic can be exercised without a real broker.\n */\n protected async createProducer(): Promise<KjsProducer> {\n const mod = await importKafkaJs();\n const kafka: KjsKafka = new mod.Kafka({\n clientId: this.opts.clientId ?? \"eventferry\",\n brokers: this.opts.brokers,\n ssl: this.opts.ssl,\n sasl: this.opts.sasl,\n });\n return kafka.producer({\n idempotent: this.opts.idempotent ?? true,\n maxInFlightRequests: this.transactional ? 1 : undefined,\n transactionalId: this.transactional ? this.opts.transactionalId : undefined,\n });\n }\n\n async disconnect(): Promise<void> {\n await this.producer?.disconnect();\n this.producer = null;\n }\n\n async sendBatch(messages: PublishableMessage[]): Promise<PublishResult[]> {\n if (!this.producer) throw new Error(\"KafkaJsDriver not connected\");\n const topicMessages = groupByTopic(messages, this.opts.compression);\n\n if (this.transactional) {\n const txn = await this.producer.transaction();\n try {\n await txn.sendBatch({ topicMessages, acks: this.opts.acks ?? -1 });\n await txn.commit();\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n await txn.abort().catch(() => undefined);\n return failedResults(messages, err);\n }\n }\n\n try {\n await this.producer.sendBatch({ topicMessages, acks: this.opts.acks ?? -1 });\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n return failedResults(messages, err);\n }\n }\n}\n\nfunction failedResults(\n messages: PublishableMessage[],\n err: unknown,\n): PublishResult[] {\n const error = err instanceof Error ? err : new Error(String(err));\n const errorKind = classifyKafkajsError(err);\n return messages.map((m) => ({\n recordId: m.recordId,\n ok: false,\n error,\n errorKind,\n }));\n}\n\nfunction groupByTopic(messages: PublishableMessage[], compression?: string) {\n const byTopic = new Map<string, unknown[]>();\n for (const m of messages) {\n const arr = byTopic.get(m.topic) ?? [];\n arr.push({\n key: m.key,\n value: m.value,\n headers: m.headers,\n });\n byTopic.set(m.topic, arr);\n }\n return [...byTopic.entries()].map(([topic, msgs]) => ({\n topic,\n messages: msgs,\n ...(compression && compression !== \"none\" ? { compression } : {}),\n }));\n}\n\nasync function importKafkaJs(): Promise<{ Kafka: new (cfg: unknown) => KjsKafka }> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (await import(\"kafkajs\")) as any;\n } catch {\n throw new Error(\n 'Driver \"kafkajs\" selected but the \"kafkajs\" package is not installed. Run: npm i kafkajs',\n );\n }\n}\n","import type { PublishErrorKind } from \"@eventferry/core\";\n\n/**\n * Classify a `@confluentinc/kafka-javascript` (librdkafka) producer error\n * into a {@link PublishErrorKind} so the core relay can decide whether to\n * retry, short-circuit to the DLQ, or pause polling.\n *\n * librdkafka exposes errors as numeric `RD_KAFKA_RESP_ERR_*` codes — negative\n * codes are library-internal (transport, queue-full, ssl), non-negative\n * codes are wire-protocol errors that match the Kafka protocol's error-code\n * registry. The confluent driver surfaces these on `err.code` (alongside\n * an `err.name` for the symbolic form).\n *\n * Unknown errors fall back to `\"retriable\"` — the safe bias.\n */\nexport function classifyConfluentError(err: unknown): PublishErrorKind {\n if (!err || typeof err !== \"object\") return \"retriable\";\n const e = err as { code?: number; name?: string };\n\n if (typeof e.code === \"number\") {\n const k = CODE_TO_KIND.get(e.code);\n if (k) return k;\n }\n\n if (typeof e.name === \"string\") {\n const k = NAME_TO_KIND.get(e.name);\n if (k) return k;\n }\n\n return \"retriable\";\n}\n\n/**\n * Authoritative mapping for the most-common librdkafka producer error codes.\n * Sources: `librdkafka/src/rdkafka.h` (`RD_KAFKA_RESP_ERR_*` enum) and the\n * Kafka Protocol error-code registry. Adding a code here is a one-line\n * change — start narrow, broaden as production exposes new codes.\n */\nconst CODE_TO_KIND: ReadonlyMap<number, PublishErrorKind> = new Map([\n // Library-internal (negative codes)\n [-184, \"backpressure\"], // ERR__QUEUE_FULL — our outbound buffer is full\n [-185, \"retriable\"], // ERR__TIMED_OUT\n [-187, \"retriable\"], // ERR__ALL_BROKERS_DOWN\n [-188, \"poison\"], // ERR__UNKNOWN_TOPIC — topic doesn't exist on broker\n [-190, \"poison\"], // ERR__UNKNOWN_PARTITION\n [-192, \"retriable\"], // ERR__MSG_TIMED_OUT\n [-195, \"retriable\"], // ERR__TRANSPORT\n [-198, \"poison\"], // ERR__BAD_COMPRESSION\n [-144, \"fatal\"], // ERR__FENCED — producer fenced by another with same txn id\n [-150, \"fatal\"], // ERR__FATAL — unrecoverable librdkafka error\n [-169, \"fatal\"], // ERR__AUTHENTICATION\n [-181, \"fatal\"], // ERR__SSL\n [-196, \"retriable\"], // ERR__FAIL — catch-all, safe-default to retriable\n\n // Wire-protocol (non-negative codes — Kafka error-code registry)\n [2, \"poison\"], // CORRUPT_MESSAGE\n [3, \"retriable\"], // UNKNOWN_TOPIC_OR_PARTITION\n [5, \"retriable\"], // LEADER_NOT_AVAILABLE\n [6, \"retriable\"], // NOT_LEADER_FOR_PARTITION\n [7, \"retriable\"], // REQUEST_TIMED_OUT\n [9, \"retriable\"], // REPLICA_NOT_AVAILABLE\n [10, \"poison\"], // MESSAGE_TOO_LARGE\n [13, \"retriable\"], // NETWORK_EXCEPTION\n [19, \"retriable\"], // NOT_ENOUGH_REPLICAS\n [29, \"fatal\"], // TOPIC_AUTHORIZATION_FAILED\n [31, \"fatal\"], // CLUSTER_AUTHORIZATION_FAILED\n [47, \"fatal\"], // INVALID_PRODUCER_EPOCH\n [58, \"fatal\"], // SASL_AUTHENTICATION_FAILED\n [74, \"retriable\"], // FENCED_LEADER_EPOCH\n [76, \"poison\"], // UNSUPPORTED_COMPRESSION_TYPE\n [87, \"poison\"], // INVALID_RECORD\n [89, \"quota\"], // THROTTLING_QUOTA_EXCEEDED\n]);\n\n/** Symbolic name fallback for clients that surface `err.name` only. */\nconst NAME_TO_KIND: ReadonlyMap<string, PublishErrorKind> = new Map([\n [\"ERR__QUEUE_FULL\", \"backpressure\"],\n [\"ERR__FENCED\", \"fatal\"],\n [\"ERR__FATAL\", \"fatal\"],\n [\"ERR__AUTHENTICATION\", \"fatal\"],\n [\"ERR__SSL\", \"fatal\"],\n [\"ERR__UNKNOWN_TOPIC\", \"poison\"],\n [\"ERR__UNKNOWN_PARTITION\", \"poison\"],\n [\"ERR__BAD_COMPRESSION\", \"poison\"],\n [\"ERR_TOPIC_AUTHORIZATION_FAILED\", \"fatal\"],\n [\"ERR_CLUSTER_AUTHORIZATION_FAILED\", \"fatal\"],\n [\"ERR_INVALID_PRODUCER_EPOCH\", \"fatal\"],\n [\"ERR_SASL_AUTHENTICATION_FAILED\", \"fatal\"],\n [\"ERR_CORRUPT_MESSAGE\", \"poison\"],\n [\"ERR_MSG_SIZE_TOO_LARGE\", \"poison\"],\n [\"ERR_INVALID_RECORD\", \"poison\"],\n [\"ERR_UNSUPPORTED_COMPRESSION_TYPE\", \"poison\"],\n [\"ERR_THROTTLING_QUOTA_EXCEEDED\", \"quota\"],\n]);\n","import type { PublishableMessage, PublishResult } from \"@eventferry/core\";\nimport { classifyConfluentError } from \"./confluent-classifier.js\";\nimport type {\n KafkaConnectionConfig,\n KafkaDriver,\n ProducerBehaviorConfig,\n} from \"./driver.js\";\n\n// Structural typing of the confluent KafkaJS-compatible API surface so this\n// file compiles without the optional native dep installed.\ninterface CkProducer {\n connect(): Promise<void>;\n disconnect(): Promise<void>;\n send(args: unknown): Promise<unknown>;\n transaction(): Promise<CkTransaction>;\n}\ninterface CkTransaction {\n send(args: unknown): Promise<unknown>;\n commit(): Promise<void>;\n abort(): Promise<void>;\n}\ninterface CkKafka {\n producer(args?: unknown): CkProducer;\n}\n\nexport interface ConfluentDriverOptions\n extends KafkaConnectionConfig,\n ProducerBehaviorConfig {}\n\n/**\n * Driver backed by `@confluentinc/kafka-javascript` (librdkafka wrapper).\n * Higher throughput; uses the KafkaJS-compatible promisified API so the\n * adapter mirrors the kafkajs driver closely.\n */\nexport class ConfluentDriver implements KafkaDriver {\n readonly transactional: boolean;\n private producer: CkProducer | null = null;\n private readonly opts: ConfluentDriverOptions;\n\n constructor(opts: ConfluentDriverOptions) {\n this.opts = opts;\n this.transactional = opts.transactional ?? false;\n if (this.transactional && !opts.transactionalId) {\n throw new Error(\n \"ConfluentDriver: transactionalId is required when transactional=true\",\n );\n }\n }\n\n async connect(): Promise<void> {\n this.producer = await this.createProducer();\n await this.producer.connect();\n }\n\n /**\n * Construct the underlying confluent producer. Overridable as a test seam so\n * the send/transaction logic can be exercised without a real broker.\n */\n protected async createProducer(): Promise<CkProducer> {\n const mod = await importConfluent();\n const kafka: CkKafka = new mod.KafkaJS.Kafka({\n kafkaJS: {\n clientId: this.opts.clientId ?? \"eventferry\",\n brokers: this.opts.brokers,\n ssl: this.opts.ssl,\n sasl: this.opts.sasl,\n },\n });\n return kafka.producer({\n kafkaJS: {\n idempotent: this.opts.idempotent ?? true,\n ...(this.transactional\n ? { transactionalId: this.opts.transactionalId }\n : {}),\n },\n });\n }\n\n async disconnect(): Promise<void> {\n await this.producer?.disconnect();\n this.producer = null;\n }\n\n async sendBatch(messages: PublishableMessage[]): Promise<PublishResult[]> {\n if (!this.producer) throw new Error(\"ConfluentDriver not connected\");\n const topicMessages = groupByTopic(messages);\n const acks = this.opts.acks ?? -1;\n const compression = this.opts.compression;\n\n const doSends = async (target: CkProducer | CkTransaction) => {\n for (const tm of topicMessages) {\n await target.send({\n topic: tm.topic,\n messages: tm.messages,\n acks,\n ...(compression && compression !== \"none\" ? { compression } : {}),\n });\n }\n };\n\n if (this.transactional) {\n const txn = await this.producer.transaction();\n try {\n await doSends(txn);\n await txn.commit();\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n await txn.abort().catch(() => undefined);\n return failedResults(messages, err);\n }\n }\n\n try {\n await doSends(this.producer);\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n return failedResults(messages, err);\n }\n }\n}\n\nfunction failedResults(\n messages: PublishableMessage[],\n err: unknown,\n): PublishResult[] {\n const error = err instanceof Error ? err : new Error(String(err));\n const errorKind = classifyConfluentError(err);\n return messages.map((m) => ({\n recordId: m.recordId,\n ok: false,\n error,\n errorKind,\n }));\n}\n\nfunction groupByTopic(messages: PublishableMessage[]) {\n const byTopic = new Map<string, unknown[]>();\n for (const m of messages) {\n const arr = byTopic.get(m.topic) ?? [];\n arr.push({ key: m.key, value: m.value, headers: m.headers });\n byTopic.set(m.topic, arr);\n }\n return [...byTopic.entries()].map(([topic, msgs]) => ({\n topic,\n messages: msgs,\n }));\n}\n\nasync function importConfluent(): Promise<{\n KafkaJS: { Kafka: new (cfg: unknown) => CkKafka };\n}> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (await import(\"@confluentinc/kafka-javascript\")) as any;\n } catch {\n throw new Error(\n 'Driver \"confluent\" selected but \"@confluentinc/kafka-javascript\" is not installed. Run: npm i @confluentinc/kafka-javascript',\n );\n }\n}\n","import type {\n PublishableMessage,\n Publisher,\n PublishResult,\n} from \"@eventferry/core\";\nimport { ConfluentDriver } from \"./confluent-driver.js\";\nimport type {\n DriverKind,\n KafkaConnectionConfig,\n KafkaDriver,\n ProducerBehaviorConfig,\n} from \"./driver.js\";\nimport { KafkaJsDriver } from \"./kafkajs-driver.js\";\n\nexport interface KafkaPublisherOptions\n extends KafkaConnectionConfig,\n ProducerBehaviorConfig {\n /** Which underlying client to use. Default \"kafkajs\". */\n driver?: DriverKind;\n /**\n * Provide a fully custom driver instance instead of the built-ins.\n * Useful for testing or unsupported clients.\n */\n customDriver?: KafkaDriver;\n}\n\n/**\n * The Publisher the Relay talks to. Wraps a pluggable KafkaDriver and\n * adds dead-letter routing. Works against Kafka and Redpanda identically\n * (Redpanda is Kafka-API compatible).\n */\nexport class KafkaPublisher implements Publisher {\n private readonly driver: KafkaDriver;\n\n constructor(opts: KafkaPublisherOptions) {\n this.driver = opts.customDriver ?? selectDriver(opts);\n }\n\n connect(): Promise<void> {\n return this.driver.connect();\n }\n\n disconnect(): Promise<void> {\n return this.driver.disconnect();\n }\n\n publish(messages: PublishableMessage[]): Promise<PublishResult[]> {\n return this.driver.sendBatch(messages);\n }\n\n /**\n * Send a single dead-lettered message. The message already carries the\n * DLQ topic (the Relay rewrites it), plus the failure reason as a header.\n */\n async publishToDlq(message: PublishableMessage, error: Error): Promise<void> {\n const dlqMessage: PublishableMessage = {\n ...message,\n headers: {\n ...message.headers,\n \"dlq-reason\": error.message,\n \"dlq-original-topic\": message.headers[\"original-topic\"] ?? \"\",\n \"dlq-failed-at\": new Date().toISOString(),\n },\n };\n const [result] = await this.driver.sendBatch([dlqMessage]);\n if (result && !result.ok) {\n throw result.error ?? new Error(\"DLQ publish failed\");\n }\n }\n\n /** Whether the configured driver provides atomic (EOS) batch sends. */\n get transactional(): boolean {\n return this.driver.transactional;\n }\n}\n\nfunction selectDriver(opts: KafkaPublisherOptions): KafkaDriver {\n const kind = opts.driver ?? \"kafkajs\";\n switch (kind) {\n case \"kafkajs\":\n return new KafkaJsDriver(opts);\n case \"confluent\":\n return new ConfluentDriver(opts);\n default:\n throw new Error(`Unknown driver \"${kind}\"`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,SAAS,qBAAqB,KAAgC;AACnE,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,QAAM,IAAI;AAGV,MAAI,EAAE,SAAS,yBAA0B,QAAO;AAChD,MAAI,EAAE,SAAS,6BAA8B,QAAO;AACpD,MAAI,EAAE,SAAS,2BAA4B,QAAO;AAMlD,QAAM,OAAO,OAAO,EAAE,SAAS,WAAW,EAAE,OAAO;AACnD,MAAI,MAAM;AACR,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["../src/index.ts","../src/kafkajs-classifier.ts","../src/transactional-id.ts","../src/kafkajs-driver.ts","../src/confluent-classifier.ts","../src/confluent-config.ts","../src/confluent-driver.ts","../src/hooks.ts","../src/tracing.ts","../src/publisher.ts"],"sourcesContent":["export * from \"./driver.js\";\nexport * from \"./kafkajs-driver.js\";\nexport * from \"./kafkajs-classifier.js\";\nexport * from \"./confluent-driver.js\";\nexport * from \"./confluent-classifier.js\";\nexport * from \"./confluent-config.js\";\nexport * from \"./hooks.js\";\nexport * from \"./tracing.js\";\nexport * from \"./publisher.js\";\n","import type { PublishErrorKind } from \"@eventferry/core\";\n\n/**\n * Classify a kafkajs producer error into a {@link PublishErrorKind} so the\n * core relay can decide whether to retry, short-circuit to the DLQ, or pause\n * polling.\n *\n * Mapping verified against `kafkajs/src/errors.js` (v2.x). Protocol error\n * codes match the Kafka Protocol error-code registry. Library-specific\n * subclasses (`KafkaJSRequestTimeoutError`, `KafkaJSConnectionError`,\n * `KafkaJSNonRetriableError`) are matched by the `name` property kafkajs\n * sets on its Error subclasses.\n *\n * Unknown errors fall back to `\"retriable\"` — the safe bias. At worst we\n * retry an error that should have been skipped; in practice we'd rather\n * over-retry than mis-classify a transient blip as terminal.\n */\nexport function classifyKafkajsError(err: unknown): PublishErrorKind {\n if (!err || typeof err !== \"object\") return \"retriable\";\n const e = err as { name?: string; type?: string; code?: number };\n\n // Class-based first — these don't carry a protocol error code.\n if (e.name === \"KafkaJSConnectionError\") return \"retriable\";\n if (e.name === \"KafkaJSRequestTimeoutError\") return \"retriable\";\n if (e.name === \"KafkaJSNonRetriableError\") return \"fatal\";\n\n // Protocol error type (string) — kafkajs's KafkaJSProtocolError exposes\n // both `type` (uppercase string) and `code` (number). Use `type` first\n // for readability and fall back to `code` for codes that lack a stable\n // string label.\n const type = typeof e.type === \"string\" ? e.type : undefined;\n if (type) {\n if (RETRIABLE_TYPES.has(type)) return \"retriable\";\n if (POISON_TYPES.has(type)) return \"poison\";\n if (FATAL_TYPES.has(type)) return \"fatal\";\n }\n\n if (typeof e.code === \"number\") {\n const k = CODE_TO_KIND.get(e.code);\n if (k) return k;\n }\n\n return \"retriable\";\n}\n\nconst RETRIABLE_TYPES = new Set<string>([\n \"NOT_LEADER_FOR_PARTITION\",\n \"LEADER_NOT_AVAILABLE\",\n \"UNKNOWN_TOPIC_OR_PARTITION\",\n \"NETWORK_EXCEPTION\",\n \"REQUEST_TIMED_OUT\",\n \"REPLICA_NOT_AVAILABLE\",\n \"NOT_ENOUGH_REPLICAS\",\n \"NOT_ENOUGH_REPLICAS_AFTER_APPEND\",\n \"FENCED_LEADER_EPOCH\",\n \"UNKNOWN_LEADER_EPOCH\",\n \"BROKER_NOT_AVAILABLE\",\n \"COORDINATOR_LOAD_IN_PROGRESS\",\n \"COORDINATOR_NOT_AVAILABLE\",\n]);\n\nconst POISON_TYPES = new Set<string>([\n \"CORRUPT_MESSAGE\",\n \"MESSAGE_TOO_LARGE\",\n \"INVALID_RECORD\",\n \"UNSUPPORTED_COMPRESSION_TYPE\",\n \"INVALID_REQUIRED_ACKS\",\n \"INVALID_PARTITIONS\",\n]);\n\nconst FATAL_TYPES = new Set<string>([\n \"INVALID_PRODUCER_EPOCH\",\n \"PRODUCER_FENCED\",\n \"TOPIC_AUTHORIZATION_FAILED\",\n \"CLUSTER_AUTHORIZATION_FAILED\",\n \"TRANSACTIONAL_ID_AUTHORIZATION_FAILED\",\n \"SASL_AUTHENTICATION_FAILED\",\n \"INVALID_TRANSACTION_STATE\",\n \"UNSUPPORTED_VERSION\",\n]);\n\n/** Numeric fallback for clusters that only return the wire code. */\nconst CODE_TO_KIND: ReadonlyMap<number, PublishErrorKind> = new Map([\n [2, \"poison\"], // CORRUPT_MESSAGE\n [3, \"retriable\"], // UNKNOWN_TOPIC_OR_PARTITION\n [5, \"retriable\"], // LEADER_NOT_AVAILABLE\n [6, \"retriable\"], // NOT_LEADER_FOR_PARTITION\n [7, \"retriable\"], // REQUEST_TIMED_OUT\n [9, \"retriable\"], // REPLICA_NOT_AVAILABLE\n [10, \"poison\"], // MESSAGE_TOO_LARGE\n [13, \"retriable\"], // NETWORK_EXCEPTION\n [19, \"retriable\"], // NOT_ENOUGH_REPLICAS\n [29, \"fatal\"], // TOPIC_AUTHORIZATION_FAILED\n [31, \"fatal\"], // CLUSTER_AUTHORIZATION_FAILED\n [47, \"fatal\"], // INVALID_PRODUCER_EPOCH\n [58, \"fatal\"], // SASL_AUTHENTICATION_FAILED\n [74, \"retriable\"], // FENCED_LEADER_EPOCH\n [76, \"poison\"], // UNSUPPORTED_COMPRESSION_TYPE\n [87, \"poison\"], // INVALID_RECORD\n]);\n","/**\n * Resolve a {@link KafkaConnectionConfig}-style `transactionalId` into the\n * concrete string the underlying driver expects.\n *\n * Accepts:\n * - `string` — used verbatim.\n * - `() => string` — invoked once at connect time.\n * - `() => Promise<string>` — awaited at connect time.\n *\n * Throws when the input is undefined (caller should pre-validate) or when\n * the callable yields an empty string.\n */\nexport async function resolveTransactionalId(\n input: string | (() => string | Promise<string>) | undefined,\n): Promise<string> {\n if (input === undefined) {\n throw new Error(\"transactionalId is required when transactional=true\");\n }\n const raw = typeof input === \"function\" ? await input() : input;\n if (typeof raw !== \"string\" || raw.length === 0) {\n throw new Error(\n \"transactionalId resolver must return a non-empty string\",\n );\n }\n return raw;\n}\n","import type {\n Logger,\n PublishableMessage,\n PublishResult,\n} from \"@eventferry/core\";\nimport { classifyKafkajsError } from \"./kafkajs-classifier.js\";\nimport { resolveTransactionalId } from \"./transactional-id.js\";\nimport type {\n KafkaConnectionConfig,\n KafkaDriver,\n KafkaJsPartitionerChoice,\n ProducerBehaviorConfig,\n} from \"./driver.js\";\n\n// Loosely-typed structural references to the kafkajs API so this file\n// compiles without kafkajs installed (it's an optional peer dep).\ninterface KjsProducer {\n connect(): Promise<void>;\n disconnect(): Promise<void>;\n // kafkajs: sendBatch takes { topicMessages }, send takes a single { topic, messages }.\n sendBatch(args: unknown): Promise<unknown>;\n transaction(): Promise<KjsTransaction>;\n}\ninterface KjsTransaction {\n sendBatch(args: unknown): Promise<unknown>;\n commit(): Promise<void>;\n abort(): Promise<void>;\n}\ninterface KjsKafka {\n producer(args?: unknown): KjsProducer;\n}\n// kafkajs's `Partitioners` namespace: three factory functions; we pluck them\n// at runtime rather than depending on the kafkajs types.\ninterface KjsPartitionersNamespace {\n DefaultPartitioner: () => unknown;\n LegacyPartitioner: () => unknown;\n JavaCompatiblePartitioner: () => unknown;\n}\n\nexport interface KafkaJsDriverOptions\n extends KafkaConnectionConfig,\n ProducerBehaviorConfig {\n /**\n * Optional logger for the driver's own diagnostics (e.g. warnings about\n * unsupported tuning options). When absent the driver falls back to\n * `console.warn` so existing users see the same output.\n */\n logger?: Logger;\n}\n\n/**\n * kafkajs producer-level knobs we expose on the typed API that kafkajs does\n * NOT actually support. On this driver these are warn-and-ignore; users\n * who need them should switch to the confluent driver.\n */\nconst UNSUPPORTED_BY_KAFKAJS = [\n \"lingerMs\",\n \"batchSize\",\n \"deliveryTimeoutMs\",\n \"maxRequestSize\",\n] as const;\n\n/**\n * Driver backed by the pure-JS `kafkajs` client. Simple, zero native deps.\n */\nexport class KafkaJsDriver implements KafkaDriver {\n readonly transactional: boolean;\n private producer: KjsProducer | null = null;\n private readonly opts: KafkaJsDriverOptions;\n\n constructor(opts: KafkaJsDriverOptions) {\n this.opts = opts;\n this.transactional = opts.transactional ?? false;\n if (this.transactional && !opts.transactionalId) {\n throw new Error(\n \"KafkaJsDriver: transactionalId is required when transactional=true\",\n );\n }\n warnUnsupportedKafkajsOptions(opts);\n }\n\n async connect(): Promise<void> {\n this.producer = await this.createProducer();\n await this.producer.connect();\n }\n\n /**\n * Construct the underlying kafkajs producer. Overridable as a test seam so\n * the send/transaction logic can be exercised without a real broker.\n */\n protected async createProducer(): Promise<KjsProducer> {\n const mod = await importKafkaJs();\n const kafka: KjsKafka = new mod.Kafka({\n clientId: this.opts.clientId ?? \"eventferry\",\n brokers: this.opts.brokers,\n // kafkajs accepts `ssl: tls.ConnectionOptions` directly — Buffer + PEM\n // string both supported. Our TlsConfig is a structural subset of that\n // (`rejectUnauthorized` intentionally omitted; the cluster CA goes via\n // `ca`). No translation needed.\n ssl: this.opts.ssl,\n // SASL: PLAIN / SCRAM-SHA-256 / SCRAM-SHA-512 / OAUTHBEARER. kafkajs's\n // shape matches ours; for OAUTHBEARER kafkajs reads only `value` from\n // the provider's returned token (other fields are ignored).\n sasl: this.opts.sasl,\n });\n const createPartitioner = resolveCreatePartitioner(\n mod.Partitioners,\n this.opts.partitioner,\n this.transactional,\n );\n // Resolve a callable transactionalId — async-safe so runtime context\n // (pod name, AZ index, k8s ordinal) can be derived at connect time.\n const resolvedTxId = this.transactional\n ? await resolveTransactionalId(this.opts.transactionalId)\n : undefined;\n return kafka.producer({\n idempotent: this.opts.idempotent ?? true,\n // Idempotent / transactional producers cap maxInFlight at 5. When the\n // user picks transactional we force 1 to keep strict ordering across\n // retries on classic (non-idempotent) clusters that haven't migrated\n // to the broker-side fence.\n maxInFlightRequests: this.transactional\n ? 1\n : this.opts.maxInFlightRequests,\n transactionalId: resolvedTxId,\n // kafkajs accepts these directly when set; undefined falls through to\n // the kafkajs default.\n requestTimeout: this.opts.requestTimeoutMs,\n transactionTimeout: this.opts.transactionTimeoutMs,\n // Setting any partitioner choice silences kafkajs's\n // KafkaJSPartitionerNotSpecified warning.\n createPartitioner,\n });\n }\n\n async disconnect(): Promise<void> {\n await this.producer?.disconnect();\n this.producer = null;\n }\n\n async sendBatch(messages: PublishableMessage[]): Promise<PublishResult[]> {\n if (!this.producer) throw new Error(\"KafkaJsDriver not connected\");\n const topicMessages = groupByTopic(messages, this.opts.compression);\n\n if (this.transactional) {\n const txn = await this.producer.transaction();\n try {\n await txn.sendBatch({ topicMessages, acks: this.opts.acks ?? -1 });\n await txn.commit();\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n await txn.abort().catch(() => undefined);\n const error = err instanceof Error ? err : new Error(String(err));\n // Notify the abort hook BEFORE returning failedResults. The hook is\n // best-effort: try/catch around it so a misbehaving hook can't make\n // the abort path itself throw.\n try {\n this.opts.onTransactionAbort?.(error);\n } catch {\n // swallow — already documented as best-effort\n }\n return failedResults(messages, err);\n }\n }\n\n try {\n await this.producer.sendBatch({ topicMessages, acks: this.opts.acks ?? -1 });\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n return failedResults(messages, err);\n }\n }\n}\n\nfunction failedResults(\n messages: PublishableMessage[],\n err: unknown,\n): PublishResult[] {\n const error = err instanceof Error ? err : new Error(String(err));\n const errorKind = classifyKafkajsError(err);\n return messages.map((m) => ({\n recordId: m.recordId,\n ok: false,\n error,\n errorKind,\n }));\n}\n\nfunction groupByTopic(messages: PublishableMessage[], compression?: string) {\n const byTopic = new Map<string, unknown[]>();\n for (const m of messages) {\n const arr = byTopic.get(m.topic) ?? [];\n arr.push({\n key: m.key,\n value: m.value,\n headers: m.headers,\n // Per-message partition override. When set, kafkajs routes the record\n // to this exact partition; when undefined, the configured partitioner\n // chooses. We keep the key here too because compacted topics need it\n // even when partition is pinned.\n ...(m.partition !== undefined ? { partition: m.partition } : {}),\n });\n byTopic.set(m.topic, arr);\n }\n return [...byTopic.entries()].map(([topic, msgs]) => ({\n topic,\n messages: msgs,\n ...(compression && compression !== \"none\" ? { compression } : {}),\n }));\n}\n\n/**\n * Resolve the `createPartitioner` factory kafkajs expects on\n * `producer({...})`. Returns `undefined` to fall through to the kafkajs\n * default when no choice is made AND the producer is non-transactional\n * (transactional producers don't trigger the no-partitioner warning).\n */\nfunction resolveCreatePartitioner(\n partitioners: KjsPartitionersNamespace | undefined,\n choice: KafkaJsPartitionerChoice | undefined,\n transactional: boolean,\n): (() => unknown) | undefined {\n if (!partitioners) return undefined;\n // Default to the java-compatible partitioner when the caller didn't pick.\n // It matches the Java client (murmur2) and silences the noisy warning;\n // for transactional producers we leave the kafkajs default alone since\n // EOS ordering is partitioner-agnostic and the warning doesn't fire there.\n const effective: KafkaJsPartitionerChoice =\n choice ?? (transactional ? \"default\" : \"java-compatible\");\n switch (effective) {\n case \"java-compatible\":\n return partitioners.JavaCompatiblePartitioner;\n case \"legacy\":\n return partitioners.LegacyPartitioner;\n case \"default\":\n return partitioners.DefaultPartitioner;\n }\n}\n\n/** Process-wide dedup so we never warn for the same option twice. */\nconst warnedKafkajsKeys = new Set<string>();\n\nfunction warnUnsupportedKafkajsOptions(opts: KafkaJsDriverOptions): void {\n for (const key of UNSUPPORTED_BY_KAFKAJS) {\n if (opts[key] === undefined) continue;\n if (warnedKafkajsKeys.has(key)) continue;\n warnedKafkajsKeys.add(key);\n const message =\n `'${key}' is not configurable on the kafkajs driver and was ignored. ` +\n `Switch to the confluent driver (driver: \"confluent\") for fine-grained tuning, ` +\n `or remove the option to silence this warning.`;\n // Route through the configured logger when present; otherwise fall back\n // to console.warn so users who never plumbed a logger still see the\n // diagnostic (matches the prior behavior).\n if (opts.logger) {\n opts.logger.warn(`[@eventferry/kafka] ${message}`, { option: key });\n } else {\n console.warn(`[@eventferry/kafka] ${message}`);\n }\n }\n}\n\n/** Internal — used by tests. Resets the dedup so warnings can be observed in isolation. */\nexport function _resetKafkajsWarnDedup(): void {\n warnedKafkajsKeys.clear();\n}\n\nasync function importKafkaJs(): Promise<{\n Kafka: new (cfg: unknown) => KjsKafka;\n Partitioners: KjsPartitionersNamespace;\n}> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (await import(\"kafkajs\")) as any;\n } catch {\n throw new Error(\n 'Driver \"kafkajs\" selected but the \"kafkajs\" package is not installed. Run: npm i kafkajs',\n );\n }\n}\n","import type { PublishErrorKind } from \"@eventferry/core\";\n\n/**\n * Classify a `@confluentinc/kafka-javascript` (librdkafka) producer error\n * into a {@link PublishErrorKind} so the core relay can decide whether to\n * retry, short-circuit to the DLQ, or pause polling.\n *\n * librdkafka exposes errors as numeric `RD_KAFKA_RESP_ERR_*` codes — negative\n * codes are library-internal (transport, queue-full, ssl), non-negative\n * codes are wire-protocol errors that match the Kafka protocol's error-code\n * registry. The confluent driver surfaces these on `err.code` (alongside\n * an `err.name` for the symbolic form).\n *\n * Unknown errors fall back to `\"retriable\"` — the safe bias.\n */\nexport function classifyConfluentError(err: unknown): PublishErrorKind {\n if (!err || typeof err !== \"object\") return \"retriable\";\n const e = err as { code?: number; name?: string };\n\n if (typeof e.code === \"number\") {\n const k = CODE_TO_KIND.get(e.code);\n if (k) return k;\n }\n\n if (typeof e.name === \"string\") {\n const k = NAME_TO_KIND.get(e.name);\n if (k) return k;\n }\n\n return \"retriable\";\n}\n\n/**\n * Authoritative mapping for the most-common librdkafka producer error codes.\n * Sources: `librdkafka/src/rdkafka.h` (`RD_KAFKA_RESP_ERR_*` enum) and the\n * Kafka Protocol error-code registry. Adding a code here is a one-line\n * change — start narrow, broaden as production exposes new codes.\n */\nconst CODE_TO_KIND: ReadonlyMap<number, PublishErrorKind> = new Map([\n // Library-internal (negative codes)\n [-184, \"backpressure\"], // ERR__QUEUE_FULL — our outbound buffer is full\n [-185, \"retriable\"], // ERR__TIMED_OUT\n [-187, \"retriable\"], // ERR__ALL_BROKERS_DOWN\n [-188, \"poison\"], // ERR__UNKNOWN_TOPIC — topic doesn't exist on broker\n [-190, \"poison\"], // ERR__UNKNOWN_PARTITION\n [-192, \"retriable\"], // ERR__MSG_TIMED_OUT\n [-195, \"retriable\"], // ERR__TRANSPORT\n [-198, \"poison\"], // ERR__BAD_COMPRESSION\n [-144, \"fatal\"], // ERR__FENCED — producer fenced by another with same txn id\n [-150, \"fatal\"], // ERR__FATAL — unrecoverable librdkafka error\n [-169, \"fatal\"], // ERR__AUTHENTICATION\n [-181, \"fatal\"], // ERR__SSL\n [-196, \"retriable\"], // ERR__FAIL — catch-all, safe-default to retriable\n\n // Wire-protocol (non-negative codes — Kafka error-code registry)\n [2, \"poison\"], // CORRUPT_MESSAGE\n [3, \"retriable\"], // UNKNOWN_TOPIC_OR_PARTITION\n [5, \"retriable\"], // LEADER_NOT_AVAILABLE\n [6, \"retriable\"], // NOT_LEADER_FOR_PARTITION\n [7, \"retriable\"], // REQUEST_TIMED_OUT\n [9, \"retriable\"], // REPLICA_NOT_AVAILABLE\n [10, \"poison\"], // MESSAGE_TOO_LARGE\n [13, \"retriable\"], // NETWORK_EXCEPTION\n [19, \"retriable\"], // NOT_ENOUGH_REPLICAS\n [29, \"fatal\"], // TOPIC_AUTHORIZATION_FAILED\n [31, \"fatal\"], // CLUSTER_AUTHORIZATION_FAILED\n [47, \"fatal\"], // INVALID_PRODUCER_EPOCH\n [58, \"fatal\"], // SASL_AUTHENTICATION_FAILED\n [74, \"retriable\"], // FENCED_LEADER_EPOCH\n [76, \"poison\"], // UNSUPPORTED_COMPRESSION_TYPE\n [87, \"poison\"], // INVALID_RECORD\n [89, \"quota\"], // THROTTLING_QUOTA_EXCEEDED\n]);\n\n/** Symbolic name fallback for clients that surface `err.name` only. */\nconst NAME_TO_KIND: ReadonlyMap<string, PublishErrorKind> = new Map([\n [\"ERR__QUEUE_FULL\", \"backpressure\"],\n [\"ERR__FENCED\", \"fatal\"],\n [\"ERR__FATAL\", \"fatal\"],\n [\"ERR__AUTHENTICATION\", \"fatal\"],\n [\"ERR__SSL\", \"fatal\"],\n [\"ERR__UNKNOWN_TOPIC\", \"poison\"],\n [\"ERR__UNKNOWN_PARTITION\", \"poison\"],\n [\"ERR__BAD_COMPRESSION\", \"poison\"],\n [\"ERR_TOPIC_AUTHORIZATION_FAILED\", \"fatal\"],\n [\"ERR_CLUSTER_AUTHORIZATION_FAILED\", \"fatal\"],\n [\"ERR_INVALID_PRODUCER_EPOCH\", \"fatal\"],\n [\"ERR_SASL_AUTHENTICATION_FAILED\", \"fatal\"],\n [\"ERR_CORRUPT_MESSAGE\", \"poison\"],\n [\"ERR_MSG_SIZE_TOO_LARGE\", \"poison\"],\n [\"ERR_INVALID_RECORD\", \"poison\"],\n [\"ERR_UNSUPPORTED_COMPRESSION_TYPE\", \"poison\"],\n [\"ERR_THROTTLING_QUOTA_EXCEEDED\", \"quota\"],\n]);\n","import type {\n KafkaConnectionConfig,\n ProducerBehaviorConfig,\n TlsConfig,\n} from \"./driver.js\";\n\n/**\n * Translate eventferry's normalized `KafkaConnectionConfig` into the shape\n * expected by `@confluentinc/kafka-javascript`'s `KafkaJS.Kafka` constructor.\n *\n * Returns an object with two parts:\n * - `kafkaJS`: the kafkajs-compatible config layer (clientId, brokers, and\n * simple ssl/sasl when no advanced TLS is needed).\n * - top-level keys: librdkafka-style config (e.g. `ssl.ca.pem`,\n * `security.protocol`) used when the user supplies a {@link TlsConfig}.\n *\n * Why a separate translator: the kafkajs-compat layer accepts the simple\n * `ssl: true` boolean but the verified path for mTLS (CA + cert + key) is\n * librdkafka's `ssl.*.pem` keys. The translator picks the right surface\n * based on what the caller supplied. Buffer inputs are coerced to strings —\n * librdkafka accepts PEM strings, NOT Buffers.\n */\nexport interface ConfluentClientConfig {\n kafkaJS: Record<string, unknown>;\n // librdkafka top-level keys; kept as a Record so we can spread them.\n librdkafka: Record<string, unknown>;\n}\n\nexport function buildConfluentClientConfig(\n opts: KafkaConnectionConfig & ProducerBehaviorConfig,\n): ConfluentClientConfig {\n const kafkaJS: Record<string, unknown> = {\n clientId: opts.clientId ?? \"eventferry\",\n brokers: opts.brokers,\n };\n const librdkafka: Record<string, unknown> = {};\n\n // ── Producer tuning passthrough (librdkafka config keys) ─────────────\n if (opts.lingerMs !== undefined) librdkafka[\"linger.ms\"] = opts.lingerMs;\n if (opts.batchSize !== undefined) librdkafka[\"batch.size\"] = opts.batchSize;\n if (opts.maxInFlightRequests !== undefined) {\n librdkafka[\"max.in.flight.requests.per.connection\"] =\n opts.maxInFlightRequests;\n }\n if (opts.requestTimeoutMs !== undefined) {\n librdkafka[\"request.timeout.ms\"] = opts.requestTimeoutMs;\n }\n if (opts.deliveryTimeoutMs !== undefined) {\n librdkafka[\"delivery.timeout.ms\"] = opts.deliveryTimeoutMs;\n }\n if (opts.maxRequestSize !== undefined) {\n librdkafka[\"message.max.bytes\"] = opts.maxRequestSize;\n }\n if (opts.transactionTimeoutMs !== undefined) {\n librdkafka[\"transaction.timeout.ms\"] = opts.transactionTimeoutMs;\n }\n\n const tlsRequested = opts.ssl === true || isTlsConfig(opts.ssl);\n const saslRequested = !!opts.sasl;\n\n if (saslRequested && tlsRequested) {\n librdkafka[\"security.protocol\"] = \"sasl_ssl\";\n } else if (tlsRequested) {\n librdkafka[\"security.protocol\"] = \"ssl\";\n } else if (saslRequested) {\n librdkafka[\"security.protocol\"] = \"sasl_plaintext\";\n } // else: leave as default (plaintext)\n\n if (isTlsConfig(opts.ssl)) {\n // Custom TLS — explicit librdkafka PEM keys. Buffers are coerced to\n // strings (librdkafka does not accept Buffer).\n const tls = opts.ssl;\n if (tls.ca !== undefined) {\n librdkafka[\"ssl.ca.pem\"] = stringifyPem(tls.ca);\n }\n if (tls.cert !== undefined) {\n librdkafka[\"ssl.certificate.pem\"] = stringifyPem(tls.cert);\n }\n if (tls.key !== undefined) {\n librdkafka[\"ssl.key.pem\"] = stringifyPem(tls.key);\n }\n if (tls.passphrase !== undefined) {\n librdkafka[\"ssl.key.password\"] = tls.passphrase;\n }\n // servername (SNI) — librdkafka derives SNI from `ssl.endpoint.identification.algorithm`;\n // explicit SNI override is not documented in the v1.x kafkaJS-compat surface, so we\n // honor it as a no-op for now and document the limitation in the gap analysis.\n } else if (opts.ssl === true) {\n // Simple TLS — kafkajs-compat boolean is sufficient.\n kafkaJS[\"ssl\"] = true;\n }\n\n if (opts.sasl) {\n // SASL — kafkajs-compat shape works for both password mechanisms and\n // OAUTHBEARER (the confluent client implements the provider callback).\n kafkaJS[\"sasl\"] = opts.sasl;\n }\n\n return { kafkaJS, librdkafka };\n}\n\nfunction isTlsConfig(v: unknown): v is TlsConfig {\n return typeof v === \"object\" && v !== null;\n}\n\nfunction stringifyPem(input: string | Buffer | Array<string | Buffer>): string {\n if (Array.isArray(input)) {\n return input.map((x) => (typeof x === \"string\" ? x : x.toString(\"utf8\"))).join(\"\\n\");\n }\n return typeof input === \"string\" ? input : input.toString(\"utf8\");\n}\n","import type { PublishableMessage, PublishResult } from \"@eventferry/core\";\nimport { classifyConfluentError } from \"./confluent-classifier.js\";\nimport { buildConfluentClientConfig } from \"./confluent-config.js\";\nimport { resolveTransactionalId } from \"./transactional-id.js\";\nimport type {\n KafkaConnectionConfig,\n KafkaDriver,\n ProducerBehaviorConfig,\n} from \"./driver.js\";\n\n// Structural typing of the confluent KafkaJS-compatible API surface so this\n// file compiles without the optional native dep installed.\ninterface CkProducer {\n connect(): Promise<void>;\n disconnect(): Promise<void>;\n send(args: unknown): Promise<unknown>;\n transaction(): Promise<CkTransaction>;\n}\ninterface CkTransaction {\n send(args: unknown): Promise<unknown>;\n commit(): Promise<void>;\n abort(): Promise<void>;\n}\ninterface CkKafka {\n producer(args?: unknown): CkProducer;\n}\n\nexport interface ConfluentDriverOptions\n extends KafkaConnectionConfig,\n ProducerBehaviorConfig {}\n\n/**\n * Driver backed by `@confluentinc/kafka-javascript` (librdkafka wrapper).\n * Higher throughput; uses the KafkaJS-compatible promisified API so the\n * adapter mirrors the kafkajs driver closely.\n */\nexport class ConfluentDriver implements KafkaDriver {\n readonly transactional: boolean;\n private producer: CkProducer | null = null;\n private readonly opts: ConfluentDriverOptions;\n\n constructor(opts: ConfluentDriverOptions) {\n this.opts = opts;\n this.transactional = opts.transactional ?? false;\n if (this.transactional && !opts.transactionalId) {\n throw new Error(\n \"ConfluentDriver: transactionalId is required when transactional=true\",\n );\n }\n }\n\n async connect(): Promise<void> {\n this.producer = await this.createProducer();\n await this.producer.connect();\n }\n\n /**\n * Construct the underlying confluent producer. Overridable as a test seam so\n * the send/transaction logic can be exercised without a real broker.\n */\n protected async createProducer(): Promise<CkProducer> {\n const mod = await importConfluent();\n const { kafkaJS, librdkafka } = buildConfluentClientConfig(this.opts);\n const kafka: CkKafka = new mod.KafkaJS.Kafka({\n kafkaJS,\n ...librdkafka,\n });\n // Resolve a callable transactionalId — async-safe so runtime context\n // (pod name, AZ index, k8s ordinal) can be derived at connect time.\n const resolvedTxId = this.transactional\n ? await resolveTransactionalId(this.opts.transactionalId)\n : undefined;\n return kafka.producer({\n kafkaJS: {\n idempotent: this.opts.idempotent ?? true,\n ...(resolvedTxId ? { transactionalId: resolvedTxId } : {}),\n },\n });\n }\n\n async disconnect(): Promise<void> {\n await this.producer?.disconnect();\n this.producer = null;\n }\n\n async sendBatch(messages: PublishableMessage[]): Promise<PublishResult[]> {\n if (!this.producer) throw new Error(\"ConfluentDriver not connected\");\n const topicMessages = groupByTopic(messages);\n const acks = this.opts.acks ?? -1;\n const compression = this.opts.compression;\n\n const doSends = async (target: CkProducer | CkTransaction) => {\n for (const tm of topicMessages) {\n await target.send({\n topic: tm.topic,\n messages: tm.messages,\n acks,\n ...(compression && compression !== \"none\" ? { compression } : {}),\n });\n }\n };\n\n if (this.transactional) {\n const txn = await this.producer.transaction();\n try {\n await doSends(txn);\n await txn.commit();\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n await txn.abort().catch(() => undefined);\n const error = err instanceof Error ? err : new Error(String(err));\n try {\n this.opts.onTransactionAbort?.(error);\n } catch {\n // swallow — abort hook is best-effort\n }\n return failedResults(messages, err);\n }\n }\n\n try {\n await doSends(this.producer);\n return messages.map((m) => ({ recordId: m.recordId, ok: true }));\n } catch (err) {\n return failedResults(messages, err);\n }\n }\n}\n\nfunction failedResults(\n messages: PublishableMessage[],\n err: unknown,\n): PublishResult[] {\n const error = err instanceof Error ? err : new Error(String(err));\n const errorKind = classifyConfluentError(err);\n return messages.map((m) => ({\n recordId: m.recordId,\n ok: false,\n error,\n errorKind,\n }));\n}\n\nfunction groupByTopic(messages: PublishableMessage[]) {\n const byTopic = new Map<string, unknown[]>();\n for (const m of messages) {\n const arr = byTopic.get(m.topic) ?? [];\n arr.push({\n key: m.key,\n value: m.value,\n headers: m.headers,\n // Per-message partition override. librdkafka honors an explicit\n // partition value; undefined leaves the default partitioner in charge.\n ...(m.partition !== undefined ? { partition: m.partition } : {}),\n });\n byTopic.set(m.topic, arr);\n }\n return [...byTopic.entries()].map(([topic, msgs]) => ({\n topic,\n messages: msgs,\n }));\n}\n\nasync function importConfluent(): Promise<{\n KafkaJS: { Kafka: new (cfg: unknown) => CkKafka };\n}> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (await import(\"@confluentinc/kafka-javascript\")) as any;\n } catch {\n throw new Error(\n 'Driver \"confluent\" selected but \"@confluentinc/kafka-javascript\" is not installed. Run: npm i @confluentinc/kafka-javascript',\n );\n }\n}\n","import type { PublishableMessage, PublishResult, Logger } from \"@eventferry/core\";\n\n/**\n * Lifecycle hooks fired by `KafkaPublisher`. Every hook is optional. The\n * publisher wraps each invocation in a try/catch and logs (via the\n * configured logger) on failure — a misbehaving hook will NEVER break\n * publishing.\n *\n * Typical wiring:\n * - Custom observability stacks (Datadog APM, New Relic) → `onPublish`,\n * `onError`, `onTransactionAbort`.\n * - Connection-aware readiness probes → `onConnect` / `onDisconnect`.\n * - Audit logs of every published record → `onPublish`.\n */\nexport interface KafkaPublisherHooks {\n /** Fires after the underlying client successfully connects. */\n onConnect?(): void | Promise<void>;\n /** Fires after the underlying client disconnects (clean shutdown). */\n onDisconnect?(): void | Promise<void>;\n /**\n * Fires once per record after a publish attempt — both successes and\n * failures. The `result.ok` flag distinguishes them.\n */\n onPublish?(\n result: PublishResult,\n message: PublishableMessage,\n ): void | Promise<void>;\n /**\n * Fires for any error surfaced from the publish path — driver-thrown\n * errors, transaction abort errors, etc. `message` is set when the error\n * is per-record; absent for batch-level errors (e.g. connect failure).\n */\n onError?(\n error: Error,\n message?: PublishableMessage,\n ): void | Promise<void>;\n /**\n * Fires when a transactional sendBatch's inner abort path is taken.\n * Useful for observability dashboards that track EOS failure rates.\n */\n onTransactionAbort?(error: Error): void | Promise<void>;\n}\n\n/**\n * Invoke a hook safely. Never throws back into the caller — logs the hook's\n * failure via the configured logger (or no-op when logger is absent).\n */\nexport async function safeHook(\n logger: Logger | undefined,\n hookName: keyof KafkaPublisherHooks,\n invoke: () => void | Promise<void> | undefined,\n): Promise<void> {\n try {\n const r = invoke();\n if (r && typeof (r as Promise<void>).then === \"function\") {\n await r;\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n logger?.warn(`[@eventferry/kafka] hook ${hookName} threw; ignored`, {\n error: error.message,\n });\n }\n}\n","/**\n * Tracing surface for the publisher.\n *\n * eventferry deliberately does not depend on `@opentelemetry/api` — instead\n * users wire a thin adapter over their tracing system (OpenTelemetry,\n * Datadog, internal, …). This file defines the minimal contract; an\n * OpenTelemetry adapter is ~10 lines (see the README).\n *\n * The contract follows the **current stable** OpenTelemetry messaging\n * semantic conventions\n * ({@link https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/kafka.md spec}):\n *\n * - Span name: `\"{topic} publish\"`\n * - `SpanKind.PRODUCER`\n * - Required attributes: `messaging.system=kafka`,\n * `messaging.operation.type=publish`, `messaging.destination.name=<topic>`\n * - Recommended: `messaging.batch.message_count`, `messaging.kafka.partition`,\n * `server.address`, `server.port`\n * - One span per batch (NOT per message — per-message spans cause\n * cardinality explosion and the spec actively warns against this)\n */\n\n/** Attribute values the spec allows. */\nexport type SpanAttributeValue = string | number | boolean;\n\n/**\n * Minimal span surface the publisher needs. Implementations wrap a\n * tracing-system-specific span; methods MUST never throw out of the\n * publisher's hot path (wrap your own SDK calls in try/catch).\n */\nexport interface SpanLike {\n setAttribute(key: string, value: SpanAttributeValue): void;\n setAttributes(attrs: Record<string, SpanAttributeValue>): void;\n /** OK on success; ERROR on failure. The `message` is the error message. */\n setStatus(status: { code: \"ok\" | \"error\"; message?: string }): void;\n /** Attach an exception to the span (OpenTelemetry `recordException`). */\n recordException(error: Error): void;\n end(): void;\n}\n\n/**\n * Factory the publisher calls once per `sendBatch` to start a span.\n * Implementations MUST set `SpanKind.PRODUCER` and the messaging semconv\n * attributes on the returned span before returning it.\n */\nexport interface KafkaTracer {\n /**\n * Start a publish span.\n * @param name Recommended format: `\"{topic} publish\"`.\n * @param attributes Initial attributes (the publisher supplies the messaging\n * semconv set: system, destination.name, operation.type,\n * batch.message_count, plus optional kafka.partition and\n * server.address/port).\n */\n startPublishSpan(\n name: string,\n attributes: Record<string, SpanAttributeValue>,\n ): SpanLike;\n}\n\n/**\n * No-op tracer. Used when the user does not configure one. Cheap allocation\n * — never touches I/O.\n */\nexport class NoopKafkaTracer implements KafkaTracer {\n startPublishSpan(): SpanLike {\n return NOOP_SPAN;\n }\n}\n\nconst NOOP_SPAN: SpanLike = {\n setAttribute() {},\n setAttributes() {},\n setStatus() {},\n recordException() {},\n end() {},\n};\n","import type {\n Logger,\n PublishableMessage,\n Publisher,\n PublishResult,\n} from \"@eventferry/core\";\nimport { ConfluentDriver } from \"./confluent-driver.js\";\nimport type {\n DriverKind,\n KafkaConnectionConfig,\n KafkaDriver,\n ProducerBehaviorConfig,\n} from \"./driver.js\";\nimport { KafkaJsDriver } from \"./kafkajs-driver.js\";\nimport { safeHook } from \"./hooks.js\";\nimport type { KafkaPublisherHooks } from \"./hooks.js\";\nimport { NoopKafkaTracer } from \"./tracing.js\";\nimport type { KafkaTracer, SpanLike } from \"./tracing.js\";\n\nexport interface KafkaPublisherOptions\n extends KafkaConnectionConfig,\n ProducerBehaviorConfig {\n /** Which underlying client to use. Default \"kafkajs\". */\n driver?: DriverKind;\n /**\n * Provide a fully custom driver instance instead of the built-ins.\n * Useful for testing or unsupported clients.\n */\n customDriver?: KafkaDriver;\n /**\n * Optional structured logger. When set, the publisher routes its own\n * diagnostics (driver warnings, hook failures) through it. When omitted,\n * the publisher is silent — only the underlying drivers may still log.\n */\n logger?: Logger;\n /**\n * Optional lifecycle hooks. Every hook is invoked safely (try/catch +\n * logged via `logger`) and a misbehaving hook will never break publishing.\n */\n hooks?: KafkaPublisherHooks;\n /**\n * Optional tracer. When set, `publish()` wraps each batch in a span that\n * follows the current stable OpenTelemetry messaging semantic conventions.\n * Use a thin adapter over your tracing SDK (see {@link KafkaTracer}).\n */\n tracer?: KafkaTracer;\n}\n\n/**\n * The Publisher the Relay talks to. Wraps a pluggable KafkaDriver and adds\n * dead-letter routing, observability hooks, and OpenTelemetry-shaped publish\n * spans. Works against Kafka and Redpanda identically (Redpanda is Kafka-API\n * compatible).\n */\nexport class KafkaPublisher implements Publisher {\n private readonly driver: KafkaDriver;\n private readonly logger: Logger | undefined;\n private readonly hooks: KafkaPublisherHooks;\n private readonly tracer: KafkaTracer;\n\n constructor(opts: KafkaPublisherOptions) {\n this.logger = opts.logger;\n this.hooks = opts.hooks ?? {};\n this.tracer = opts.tracer ?? new NoopKafkaTracer();\n // Plumb the logger into driver construction so driver-side diagnostics\n // (e.g. kafkajs unsupported-tuning warnings) route through it too.\n // Plumb a safe-wrapped onTransactionAbort callback so the driver-level\n // transaction abort path fans out to the user-supplied hook safely.\n const onTransactionAbort = this.hooks.onTransactionAbort\n ? (error: Error) => {\n void safeHook(this.logger, \"onTransactionAbort\", () =>\n this.hooks.onTransactionAbort?.(error),\n );\n }\n : undefined;\n this.driver =\n opts.customDriver ?? selectDriver({ ...opts, onTransactionAbort });\n }\n\n async connect(): Promise<void> {\n await this.driver.connect();\n await safeHook(this.logger, \"onConnect\", () => this.hooks.onConnect?.());\n }\n\n async disconnect(): Promise<void> {\n await this.driver.disconnect();\n await safeHook(this.logger, \"onDisconnect\", () =>\n this.hooks.onDisconnect?.(),\n );\n }\n\n async publish(messages: PublishableMessage[]): Promise<PublishResult[]> {\n if (messages.length === 0) return [];\n\n const span = this.startBatchSpan(messages);\n let results: PublishResult[];\n try {\n results = await this.driver.sendBatch(messages);\n } catch (err) {\n // Driver-level throw — every record is a failure attributed to the\n // batch-level error. Record on the span, fire hook, rethrow.\n const error = err instanceof Error ? err : new Error(String(err));\n span.setStatus({ code: \"error\", message: error.message });\n span.recordException(error);\n span.end();\n await safeHook(this.logger, \"onError\", () => this.hooks.onError?.(error));\n throw err;\n }\n\n // Per-record hooks. Walk by index so the original message is available.\n const byId = new Map(messages.map((m) => [m.recordId, m]));\n let allOk = true;\n for (const r of results) {\n const msg = byId.get(r.recordId);\n if (!msg) continue;\n await safeHook(this.logger, \"onPublish\", () =>\n this.hooks.onPublish?.(r, msg),\n );\n if (!r.ok) {\n allOk = false;\n const err = r.error ?? new Error(\"publish failed\");\n await safeHook(this.logger, \"onError\", () =>\n this.hooks.onError?.(err, msg),\n );\n }\n }\n\n span.setStatus(allOk ? { code: \"ok\" } : { code: \"error\" });\n span.end();\n return results;\n }\n\n /**\n * Send a single dead-lettered message. The message already carries the\n * DLQ topic (the Relay rewrites it), plus the failure reason as a header.\n */\n async publishToDlq(message: PublishableMessage, error: Error): Promise<void> {\n const dlqMessage: PublishableMessage = {\n ...message,\n headers: {\n ...message.headers,\n \"dlq-reason\": error.message,\n \"dlq-original-topic\": message.headers[\"original-topic\"] ?? \"\",\n \"dlq-failed-at\": new Date().toISOString(),\n },\n };\n const [result] = await this.driver.sendBatch([dlqMessage]);\n if (result && !result.ok) {\n throw result.error ?? new Error(\"DLQ publish failed\");\n }\n }\n\n /** Whether the configured driver provides atomic (EOS) batch sends. */\n get transactional(): boolean {\n return this.driver.transactional;\n }\n\n /**\n * Start a span for the batch following the OTel messaging conventions.\n *\n * Multi-topic batches: per the OTel spec, the span name uses the\n * destination — we pick the FIRST topic in the batch and document the\n * limitation. Callers that publish heterogeneous batches and care about\n * per-topic spans should split their batches upstream.\n */\n private startBatchSpan(messages: PublishableMessage[]): SpanLike {\n const topic = messages[0]?.topic ?? \"unknown\";\n return this.tracer.startPublishSpan(`${topic} publish`, {\n \"messaging.system\": \"kafka\",\n \"messaging.operation.type\": \"publish\",\n \"messaging.destination.name\": topic,\n \"messaging.batch.message_count\": messages.length,\n });\n }\n}\n\nfunction selectDriver(opts: KafkaPublisherOptions): KafkaDriver {\n const kind = opts.driver ?? \"kafkajs\";\n switch (kind) {\n case \"kafkajs\":\n return new KafkaJsDriver(opts);\n case \"confluent\":\n return new ConfluentDriver(opts);\n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C5C,CAAC;AAAA,EACH;AACF;AAEA,SAAS,aAAa,MAA0C;AAC9D,QAAM,OAAO,KAAK,UAAU;AAC5B,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,IAAI,cAAc,IAAI;AAAA,IAC/B,KAAK;AACH,aAAO,IAAI,gBAAgB,IAAI;AAAA,IACjC;AACE,YAAM,IAAI,MAAM,mBAAmB,IAAI,GAAG;AAAA,EAC9C;AACF;","names":["CODE_TO_KIND","groupByTopic","failedResults"]}
|
package/dist/index.d.cts
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 };
|