Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress warnings about default partitioner #44

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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