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

Improve setup to facilitate integration testing and future service setup #285

Merged
merged 6 commits into from
Jan 16, 2025

Conversation

SimonHeybrock
Copy link
Member

Not much of a test yet, but I hope this provides the foundation.

Comment on lines +42 to +47
key = message.key().decode('utf-8')
value = json.loads(message.value().decode('utf-8'))
self._logger.info(
'Updating config: %s = %s at %s', key, value, message.timestamp()
)
self._config[key] = value
Copy link
Member

Choose a reason for hiding this comment

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

I think we should be careful of using key in this case.
key is for associating the messages with a certain partition, so it's mainly for the broker not the consumer.
https://www.confluent.io/learn/kafka-message-key/

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to new issue #286, since this is unrelated to this change (just moved code).

'Updating config: %s = %s at %s', key, value, msg.timestamp()
)
self._config[key] = value
messages = self._consumer.consume(num_messages=100, timeout=0.1)
Copy link
Member

Choose a reason for hiding this comment

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

Why does the config consumer need to consume so many messages at once?

Copy link
Member Author

Choose a reason for hiding this comment

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

To enable better batching and minimize the number of back and forth with the broker? True, this usually does not happen as few values are updated, but it does when loading initial config or catching up after restart.

Do you think it is harmful?

Copy link
Member

Choose a reason for hiding this comment

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

No, since the timeout is very small, it should be fine.

Base automatically changed from config-handling to main January 16, 2025 12:54
Copy link
Member

Choose a reason for hiding this comment

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

Will it be easier to write a mock object instead of making a fake consumer class from scratch?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know?

Copy link
Member

Choose a reason for hiding this comment

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

We can just have it in mind as an alternative to write a fake object in case it becomes too complicated later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, feel free to refactor when writing more tests, in case a mocking approach is more convenient.

@SimonHeybrock SimonHeybrock merged commit 6f431bd into main Jan 16, 2025
4 checks passed
@SimonHeybrock SimonHeybrock deleted the integration-testing branch January 16, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants