-
Notifications
You must be signed in to change notification settings - Fork 933
Make Message Object Instantiable By Users #2128
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
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
MSeal
left a comment
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.
Thanks for adding tests covering various init behaviors
|
|
Message class was intentionally like this because we didn't want user to instantiate a message. There are some APIs which take message as input like We can choose from the below:
|
|
@pranavrth I advised against the Mock providing here as it won't solve the root issues and this is a non-default sharp edge that the user can be responsible for if they misuse. I suggested we either do checks on the init or checks in method uses to ensure bad inputs raises a clean exception if we want to prevent deep failures from bad inputs. But I also imagine 90% of the cases here will be user knowingly instantiating an object they know isn't real for e2e patterns. |


Overview
Messageobjects to be instantiable by users.topic(),partition()andoffset()getters to make them consistent with their implementations (ref)Problem
Users were unable to create synthetic
Messageobjects in their unit tests and had to resort to reading Message objects from a live Kafka cluster.Solution
A constructor has been defined in the Message class. All params have been intentionally kept optional to support easy instantiation without providing any params. This way of creating new messages is expected to be used only while writing unit tests. Producers and consumers will continue to use the internal factory method (
Message_new0) for creating message objects.Checklist
References
#1535