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 builder for Backoff #5488

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

kth496
Copy link
Contributor

@kth496 kth496 commented Mar 6, 2024

Motivation:

Modifications:

  • Add Builder class for various backoff implementations.

Result:

return new Builder();
}

public static class Builder {
Copy link
Contributor

Choose a reason for hiding this comment

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

Code style) We prefer top-level builder classes instead of nested classes.
Could you move this class to ExpontionalBackoffBuilder?

Comment on lines +99 to +101
public static Builder builder() {
return new Builder();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding a builder method to each implementation, should we add a builder method Backoff interface?

interface Backoff {
   static ExpontionalBackoffBuilder builderForExpontional() {
      ...
   }
}

Note that ExponentialBackoff is a package-private class that users can't access.

return new ExponentialBackoff(initialDelayMillis, maxDelayMillis, multiplier);
}

public Builder initialDelayMillis(long initialDelayMillis) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make jitter values configured with this builder?

private long maxDelayMillis;

FibonacciBackoff build() {
return new FibonacciBackoff(initialDelayMillis, maxDelayMillis);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we migrate all factory methods where constructors are used into builder methods? e.g.

return new ExponentialBackoff(initialDelayMillis, maxDelayMillis, multiplier);

@kth496
Copy link
Contributor Author

kth496 commented Mar 26, 2024

@ikhoon Thank you for your review. I will fix it within a week.

@kth496 kth496 marked this pull request as draft March 27, 2024 15:10
@github-actions github-actions bot added the Stale label Apr 27, 2024
@trustin
Copy link
Member

trustin commented May 8, 2024

@kth496 Looking forward to seeing more commits in this PR 💟

@github-actions github-actions bot removed the Stale label May 9, 2024
@trustin
Copy link
Member

trustin commented Jun 6, 2024

@kth496 Any updates?

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.

Add builder for Backoff
3 participants