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

Add support for subscribing to topics by regex #433

Merged

Conversation

demetris-manikas
Copy link
Contributor

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.

@demetris-manikas demetris-manikas changed the title This PR adds support for subscribing to topics by regex Add support for subscribing to topics by regex May 9, 2024
@@ -20,6 +20,9 @@ const kafkaConfig: KafkaConfig = {
logLevel: logLevel.NOTHING, // FOR TESTING
}
const kafka = new KafkaJS(kafkaConfig)
const patternTopic = /dbos-test-.*/;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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... :)

Copy link
Contributor

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

Copy link
Contributor

@kraftp kraftp left a 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.

@demetris-manikas demetris-manikas force-pushed the kafka-consume-support-pattern-topics branch from 0a81688 to 5d0b597 Compare May 9, 2024 20:18
@demetris-manikas
Copy link
Contributor Author

Rebased and waiting review

DBOSTestClass.patternTopicResolve();
}
}
return DBOSTestClass.patternTopicPromise;
Copy link
Contributor

@kraftp kraftp May 9, 2024

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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).

@demetris-manikas
Copy link
Contributor Author

Suggestions applied

Copy link
Contributor

@kraftp kraftp left a 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.

@kraftp kraftp merged commit fb63858 into dbos-inc:main May 9, 2024
2 checks passed
@demetris-manikas
Copy link
Contributor Author

Happy to help.
I guess you are not interested in implementing the topics functionality along with topic since you did not comment on it.

@kraftp
Copy link
Contributor

kraftp commented May 9, 2024

I think that would also be a good change, if slightly more involved

@demetris-manikas
Copy link
Contributor Author

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.
Which way you recommend?

@kraftp
Copy link
Contributor

kraftp commented May 9, 2024

Defining topic in our decorator as string | RegExp | Array<string | RegExp> makes the most sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants