pulsar-client-go icon indicating copy to clipboard operation
pulsar-client-go copied to clipboard

[fix] Reconnection logic and Backoff policy doesn't work correctly

Open crossoverJie opened this issue 1 year ago • 2 comments

Fixes #1187

Modifications

  • Move backoff.go to the backoff directory (because there are circular dependencies, they are not moved to the pulsar directory.)
  • Create a new method for BackOffPolicy interface IsMaxBackoffReached(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

crossoverJie avatar Mar 13 '24 12:03 crossoverJie

@RobertIndie PTAL

crossoverJie avatar Mar 20 '24 15:03 crossoverJie

Perhaps we could consider including this change in the 1.0 version.

Yes, I agree with you.

crossoverJie avatar Mar 29 '24 14:03 crossoverJie

Any updates?

nodece avatar Jul 06 '24 17:07 nodece

@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?

crossoverJie avatar Jul 07 '24 08:07 crossoverJie

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

nodece avatar Jul 07 '24 14:07 nodece

Package: internal->backoff Interface name: BackoffPolicy-> Policy

Update:

BackoffPolicy internal.BackoffPolicy -> BackOffPolicyFunc func() backoff.Policy:

  1. Because the Policy is concurrently called in the consumer, it has been modified to obtain a policy object each time using the backoffPolicyFunc function.

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

  1. A new Reset function has been added to the Policy interface, 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 this Reset function.

crossoverJie avatar Jul 10 '24 08:07 crossoverJie