-
Notifications
You must be signed in to change notification settings - Fork 796
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 the field to avoid creating missing topic. #873
Add the field to avoid creating missing topic. #873
Conversation
Add field AllowAutoTopicCreation to Writer struct. It prevents the side-effect of creating missing topic. Closes segmentio#872
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.
It looks like tests that relied on automatic topic creation are failing (which seems expected), for example:
--- FAIL: TestWriter (0.00s)
--- FAIL: TestWriter/writing_a_message_to_a_non-existant_topic_creates_the_topic (0.02s)
writer_test.go:735: unexpected error [3] Unknown Topic Or Partition: the request is for a topic or partition that does not exist on this broker
writer_test.go:736: [3] Unknown Topic Or Partition: the request is for a topic or partition that does not exist on this broker
Do you think you could update the tests to account for the behavior change?
@@ -185,6 +185,9 @@ type Writer struct { | |||
// If nil, DefaultTransport is used. | |||
Transport RoundTripper | |||
|
|||
// AllowAutoTopicCreation notifies writer to create topic is missing. |
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.
While it's not a breaking change per-say since the code will continue to compile, the new behavior we introduce is the inverse of what the program used to do.
Do you think we could add a bit more documentation to reflect that fact?
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.
@achille-roussel hey! indeed, you are right wrt docu update. I update the test case as well.
Add the feature on the Writer's features list. Add a code snippet to create a topic before messages publication. Closes segmentio#872
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.
Just some minor language nits in comments & strings.
Co-authored-by: Erik Weathers <[email protected]>
language adjustment @erikdw Co-authored-by: Erik Weathers <[email protected]>
Adjust styling by @erikdw Co-authored-by: Erik Weathers <[email protected]>
Hey @erikdw, thanks for your feedback. Suggested changes have been applied. |
@kislerdm : Thanks for accepting the suggested edits! I'll leave final approval to @achille-roussel since he left some more functional comments. |
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.
Looking good!
@@ -185,6 +185,9 @@ type Writer struct { | |||
// If nil, DefaultTransport is used. | |||
Transport RoundTripper | |||
|
|||
// AllowAutoTopicCreation notifies writer to create topic is missing. | |||
AllowAutoTopicCreation bool |
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.
Any reason to not introduce this in the writer config too?
#1278
If I am using WriterConfig to create the writer, is it safe to just set this config after calling NewWriter
?
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.
@erikdw @achille-roussel Here's a PR in case 1278 is a desirable feature request: #1279 if
Add field AllowAutoTopicCreation to Writer struct.
It prevents the side-effect of creating missing topic.
Closes #872