[fix] Reconnection logic and Backoff policy doesn't work correctly
Fixes #1187
Modifications
- Move
backoff.goto thebackoffdirectory (because there are circular dependencies, they are not moved to the pulsar directory.) - Create a new method for
BackOffPolicyinterfaceIsMaxBackoffReached(delayReconnectTime, totalDelayReconnectTime time.Duration) bool
This is a breaking change that modifies the package name and interface name.
Package: internal->backoff
Interface name: BackoffPolicy-> Policy
Verifying this change
- [x] Make sure that the change passes the CI checks.
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): (no)
- The public API: (yes)
- The schema: (no)
- The default values of configurations: (no)
- The wire protocol: (no)
Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (GoDocs)
- 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
@RobertIndie PTAL
Perhaps we could consider including this change in the 1.0 version.
Yes, I agree with you.
Any updates?
@nodece The code conflicts have been resolved, but this PR involves changes to the public API. Do you recommend releasing it in version v0.13.0?
This is a breaking change that modifies the package name and interface name.
A breaking change that we add new method to the Backoff interface, not change package name.
In the user project, the user cannot import the internal package of the pulsar library, this is a limitation, please check https://go.dev/doc/modules/layout
Package:
internal->backoffInterface name:BackoffPolicy->Policy
Update:
BackoffPolicy internal.BackoffPolicy -> BackOffPolicyFunc func() backoff.Policy:
- Because the Policy is concurrently called in the consumer, it has been modified to obtain a
policyobject each time using thebackoffPolicyFuncfunction.
https://github.com/apache/pulsar-client-go/blob/1152cfc2e3c2024117ecff93a46d90e7eab0fa15/pulsar/consumer_partition.go#L1709-L1712
https://github.com/apache/pulsar-client-go/blob/1152cfc2e3c2024117ecff93a46d90e7eab0fa15/pulsar/consumer_partition.go#L607-L609
- A new
Resetfunction has been added to thePolicyinterface, which will be called after a successful reconnection. If a user's custom Policy requires the reuse of the same object, the data can be reset within thisResetfunction.