Skip to content

Commit

Permalink
Merge pull request #44 from lpsinger/suppress-default-paritioner-warning
Browse files Browse the repository at this point in the history
Suppress warnings about default partitioner
  • Loading branch information
dakota002 authored Nov 6, 2024
2 parents 7108638 + 88106da commit dbb0204
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import {
CompressionCodecs,
CompressionTypes,
Kafka as BaseKafka,
Partitioners,
} from 'kafkajs'
import type {
KafkaConfig as BaseKafkaConfig,
ConsumerConfig as BaseConsumerConfig,
ProducerConfig,
} from 'kafkajs'
import { Issuer } from 'openid-client'
import { randomUUID } from 'crypto'
Expand Down Expand Up @@ -69,6 +71,14 @@ class Kafka extends BaseKafka {
groupId ??= randomUUID()
return super.consumer({ groupId, ...config })
}

producer({ createPartitioner, ...config }: ProducerConfig = {}) {
// Suppress default partitioner warning.
// FIXME: remove once KafkaJS has removed the warning.
// See https://kafka.js.org/docs/migration-guide-v2.0.0#producer-new-default-partitioner
createPartitioner ??= Partitioners.DefaultPartitioner
return super.producer({ createPartitioner, ...config })
}
}

export * from 'kafkajs'
Expand Down

0 comments on commit dbb0204

Please sign in to comment.