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

Add the field to avoid creating missing topic. #873

Merged

Conversation

kislerdm
Copy link
Contributor

Add field AllowAutoTopicCreation to Writer struct.
It prevents the side-effect of creating missing topic.

Closes #872

Add field AllowAutoTopicCreation to Writer struct.
It prevents the side-effect of creating missing topic.

Closes segmentio#872
@achille-roussel achille-roussel self-assigned this Mar 27, 2022
Copy link
Contributor

@achille-roussel achille-roussel left a 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.
Copy link
Contributor

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?

Copy link
Contributor Author

@kislerdm kislerdm Mar 27, 2022

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.

Dmitry Kisler added 3 commits March 27, 2022 23:56
Add the feature on the Writer's features list.
Add a code snippet to create a topic before messages publication.

Closes segmentio#872
Copy link
Contributor

@erikdw erikdw left a 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.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
writer_test.go Outdated Show resolved Hide resolved
kislerdm and others added 3 commits March 30, 2022 08:46
Co-authored-by: Erik Weathers <erikdw@gmail.com>
language adjustment @erikdw

Co-authored-by: Erik Weathers <erikdw@gmail.com>
Adjust styling by @erikdw

Co-authored-by: Erik Weathers <erikdw@gmail.com>
@kislerdm
Copy link
Contributor Author

Just some minor language nits in comments & strings.

Hey @erikdw, thanks for your feedback. Suggested changes have been applied.

@erikdw
Copy link
Contributor

erikdw commented Mar 30, 2022

@kislerdm : Thanks for accepting the suggested edits! I'll leave final approval to @achille-roussel since he left some more functional comments.

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

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

Looking good!

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.

Adjust Writer in order to explicitly set AllowAutoTopicCreation for the WriteMessages method
3 participants