-
Notifications
You must be signed in to change notification settings - Fork 17
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
KafkaConsume accept array of string or RegExp #436
KafkaConsume accept array of string or RegExp #436
Conversation
Needs a bit more work. I 'll let you know when is ready. |
It's ok now. |
tests/kafka/kafka.test.ts
Outdated
@Workflow() | ||
static async testConsumeTopicsArray(_ctxt: WorkflowContext, topic: string, _partition: number, message: KafkaMessage) { | ||
const isWfMessage = topic == wfTopic && message.value?.toString() === wfMessage; | ||
const isTxnMessage = txnTopic && message.value?.toString() === txnMessage; |
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 this be topic === txnTopic
?
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.
Sure! Copy pasta mistake!
src/kafka/kafka.ts
Outdated
@@ -135,14 +142,26 @@ export class DBOSKafka { | |||
} | |||
} | |||
|
|||
safeGroupName(topics: Array<string | RegExp>) { | |||
const res= topics.map(r => r.toString()).map( r=> r.replaceAll(/[^a-zA-Z0-9\\-]/g, '')).join('-'); |
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.
Good catch!
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.
Good change, just minor nits (and remove the console.log
) and we can merge!
Added a max length check as well. |
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.
Looks good!
This PR adds support for declaring an array of topics for a consumer.