-
Notifications
You must be signed in to change notification settings - Fork 2
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
Migrate KafkaJS to ^2.0.0 #384
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ import requireInjected from '../../require-injected'; | |
import { KafkaConfig } from '../../typings/kafka'; | ||
import type * as KafkajsType from 'kafkajs'; | ||
import { flatten, isEmpty } from 'lodash'; | ||
|
||
const { Kafka }: typeof KafkajsType = requireInjected('kafkajs'); | ||
const { Kafka, Partitioners }: typeof KafkajsType = requireInjected('kafkajs'); | ||
const logger = getLogger('orka.kafka'); | ||
|
||
export default class OrkaKafka { | ||
|
@@ -35,6 +34,7 @@ export default class OrkaKafka { | |
authenticationTimeout | ||
}); | ||
|
||
if (options && !options.createPartitioner) options.createPartitioner = Partitioners.DefaultPartitioner; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add the ability to define the partitioner in docs too? |
||
this.producer = this.produceClient.producer(options); | ||
|
||
const { CONNECT, DISCONNECT } = this.producer.events; | ||
|
@@ -109,11 +109,11 @@ export default class OrkaKafka { | |
const renamings = await Promise.all( | ||
groupIds | ||
.map(async ({ groupId, topic, oldGroupId }) => { | ||
const offsets = await admin.fetchOffsets({ groupId, topic, resolveOffsets: false }); | ||
if (offsets.every(({ offset }) => offset === '-1')) { | ||
const [offsets] = await admin.fetchOffsets({ groupId, topics: [topic], resolveOffsets: false }); | ||
if (offsets.partitions.every(({ offset }) => offset === '-1')) { | ||
// groupId is not configured | ||
const oldOffsets = await admin.fetchOffsets({ groupId: oldGroupId, topic, resolveOffsets: false }); | ||
const knownOffsets = oldOffsets?.filter(o => o.offset !== '-1'); | ||
const [oldOffsets] = (await admin.fetchOffsets({ groupId: oldGroupId, topics: [topic], resolveOffsets: false })); | ||
const knownOffsets = oldOffsets.partitions.filter(o => o.offset !== '-1'); | ||
if (!isEmpty(knownOffsets)) await admin.setOffsets({ groupId, topic, partitions: knownOffsets }); | ||
return { groupId, renamedFrom: oldGroupId, topic, oldOffsets: knownOffsets }; | ||
} else { | ||
|
@@ -179,7 +179,6 @@ function getAuthOptions(options: { | |
}) { | ||
const { key, cert, ca } = options.certificates || {}; | ||
if (key && cert && ca) return { ssl: { ...options.certificates, ca: flatten([ca]) } }; | ||
|
||
const { username, password } = options.sasl || {}; | ||
if (username && password) return { sasl: options.sasl, ssl: options.ssl }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't accept
number
keys too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm these are the only values accepted by kafkajs typings for the message key.
I believe that all values are either treated as string or binary data.
Do you have a specific case you want me to take another look?