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

KafkaSinkCluster: refactor #1287

Merged
merged 4 commits into from
Aug 17, 2023
Merged

Conversation

rukai
Copy link
Member

@rukai rukai commented Aug 15, 2023

Its been a while since I wrote this code and I can see now that its quite hard to understand.
This PR is an attempt to fix that by:

  • rename coordinator_broker_id to group_to_coordinator_broker
    • it is a map so its important to convey what values maps to what.
  • Swap to kafka-protocols newtype wrappers e.g. StrBytes -> GroupId, StrBytes -> TopicName, i32 -> BrokerId
    • This improves type safety by ensuring that we cant mixup a group id with a topic name.
    • Also documents the purpose of the type making the code easier to understand.
    • Doesnt end up complicating things much at all since we were often extracting the inner StrBytes from the newtype only to reconstruct the newtype again later on when we passed the value back to kafka-protocol
  • Pull large chunks of logic into new functions e.g. find_coordinator_of_group and get_metadata_of_topics

@rukai rukai force-pushed the cleanup_kafka_sink_cluster branch from f2f9a0a to 1d80a22 Compare August 15, 2023 01:44
Copy link
Member

@benbromhead benbromhead left a comment

Choose a reason for hiding this comment

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

Nice, great readability improvement

@rukai rukai enabled auto-merge (squash) August 16, 2023 21:04
@rukai rukai merged commit a9439c5 into shotover:main Aug 17, 2023
15 checks passed
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.

3 participants