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

Make PartitionsAutoDiscoveryInterval configurable #514

Merged

Conversation

hunter2046
Copy link
Contributor

@hunter2046 hunter2046 commented May 5, 2021

Motivation

partitionsAutoDiscoveryInterval is currently hardcoded to 1 minute:

var partitionsAutoDiscoveryInterval = 1 * time.Minute

I could think of two reasons for making it a configurable value:

  • A faster or slower partitions discovery is desired. A faster one is more likely when users would like a partition increment to be effective more quickly.
  • Allow a test to be able to set it to a much smaller time duration so that the test could exercise the logic within a reasonable short time

Modifications

Added PartitionsAutoDiscoveryInterval into ProducerOptions with a default value of 1 minute.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API: (yes / no)
  • The schema: (yes / no / don't know)
  • The default values of configurations: (yes / no)
  • The wire protocol: (yes / no)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / GoDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

@@ -87,6 +88,9 @@ func newProducer(client *client, options *ProducerOptions) (*producer, error) {
if options.BatchingMaxPublishDelay <= 0 {
options.BatchingMaxPublishDelay = defaultBatchingMaxPublishDelay
}
if options.PartitionsAutoDiscoveryInterval == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if a negative value is passed in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch. Updated the check to include negative values.

@hunter2046 hunter2046 force-pushed the configurable-partitions-discovery-interval branch from 58ba5db to f2709b8 Compare May 12, 2021 21:01
@merlimat merlimat merged commit 6426d39 into apache:master May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants