-
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
Add support for subscribing to topics by regex #433
Add support for subscribing to topics by regex #433
Conversation
tests/kafka/kafka.test.ts
Outdated
@@ -20,6 +20,9 @@ const kafkaConfig: KafkaConfig = { | |||
logLevel: logLevel.NOTHING, // FOR TESTING | |||
} | |||
const kafka = new KafkaJS(kafkaConfig) | |||
const patternTopic = /dbos-test-.*/; |
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.
Maybe make this in as a RegExp
object?
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.
It is. Try doting it. I can make it explicit if you wish.
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.
How is it that you prefer it ? new RegExp('dbos-test-.*')
or new RegExp(/dbos-test-.*/)?
they all do the same. Javascript. More ways to do the same thing than anyone needs... :)
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.
Yeah, making it explicit with the latter notation is good
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.
Nice change! After the outstanding Kafka fix PR (#434) is merged, let's rebase this on top and merge it.
0a81688
to
5d0b597
Compare
Rebased and waiting review |
tests/kafka/kafka.test.ts
Outdated
DBOSTestClass.patternTopicResolve(); | ||
} | ||
} | ||
return DBOSTestClass.patternTopicPromise; |
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.
Don't return promises from operations (it can cause failures because they're not serializable), just await them like in the other tests
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.
It is not a big deal here cause it is just a test but why await? the caller awaits if he cares to. I ve learned not to await unless needed (can very easily create synchronous code where you don't expect it ).
As you wish though.
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.
I also have learned to use explicit returns. (burned sometimes for not doing it in nestjs).
Suggestions applied |
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! Thanks for implementing our suggestions.
Happy to help. |
I think that would also be a good change, if slightly more involved |
Shoot.. The 'topic' way is deprecated. Should have been an array from the start, I guess it is too late to change the Decorator so I have to create another one or have topic defined as string | RegExp | Array<string | RegExp> which is not that bad except for the variable name. Apart from that the implementation is quite easy. |
Defining |
kafkajs provides support for it so why not expose it?
This can be extended so as to receive an Array<string | RegExp> instead of just one.