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

Factor out kafka async wrapper code #12

Merged
merged 2 commits into from
Oct 29, 2020
Merged

Conversation

ottomata
Copy link
Contributor

This code has been moved to a separate module:
@wikimedia/node-rdkafka-factory

and added here as an optional dependency. The default-eventgate
factory will only attempt to require this if kafka.conf is set.

By factoring out this code, custom EventGate implementations
can require is separately from EventGate to create their own
Kafka produce functions.

Bug: T266058

This code has been moved to a separate module:
  @wikimedia/node-rdkafka-factory

and added here as an optional dependency.  The default-eventgate
factory will only attempt to require this if kafka.conf is set.

By factoring out this code, custom EventGate implementations
can require is separately from EventGate to create their own
Kafka produce functions.

Bug: T266058
@ottomata
Copy link
Contributor Author

@wikimedia/node-rdkafka-factory initial commit for review is here: https://gerrit.wikimedia.org/r/c/node-rdkafka-factory/+/637026

We need to merge and publish that before this is merged.

README.md Outdated Show resolved Hide resolved
config.yaml Outdated Show resolved Hide resolved
config.yaml Outdated Show resolved Hide resolved
*/
function makeProduce(options, producer) {
async function makeKafkaProduce(options, logger, metrics) {
const kafka = require('node-rdkafka-factory');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe wrap in try-catch and re-throw with a nice error message and a hint to install the dependency?

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 think in this case the Error that is thrown is decent (and standard) when a dependency is not installed.

lib/factories/default-eventgate.js Show resolved Hide resolved
Bug: T266058
@ottomata ottomata merged commit 6cdc985 into wikimedia:master Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants