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 InitialReconnectBackoffWindow a function and add ForceInitialBackoff #129

Merged
merged 1 commit into from Dec 5, 2017

Conversation

oconnor663
Copy link

These changes will allow client to back off of gregor reconnects, based on whether the current device is active in chat.

r? @mmaxim

@@ -336,7 +336,12 @@ type ConnectionOpts struct {
// InitialReconnectBackoffWindow, if non zero, causes a random backoff
// before reconnecting. The random backoff timer is fast-forward-able by
// passing in a WithFireNow(ctx) into a RPC call.
InitialReconnectBackoffWindow time.Duration
InitialReconnectBackoffWindow func() time.Duration
// As the name suggests, we normally skip the "initial REconnect backoff"
Copy link

Choose a reason for hiding this comment

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

s/REconnect/reconnect

Copy link

Choose a reason for hiding this comment

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

I have a slight preference for an interface here which includes a GetReconnectBackoffWindow() method. But I'm OK with this too.

Please update the comment to reflect that this field is now a function.

The other thing is that I actually don't remember why this was named InitialReconnectBackOffWindow rather than ReconnectBackOffWindow. Maybe I planned to have it changeable, but that doesn't seem to be the case anymore, so the naming is a bit confusing now. So if you think the latter is better, feel free to change it!

Copy link
Author

Choose a reason for hiding this comment

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

The reason it's not ReconnectBackOffWindow is because there's also a ReconnectBackoff function immediately above. Perhaps the Right Thing would be to combine the two, but I tried not to change more than I needed to here.

@jzila
Copy link

jzila commented Dec 5, 2017

cc @songgao

Copy link

@songgao songgao left a comment

Choose a reason for hiding this comment

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

Code looks good to me. Just one nit and a suggestion.

InitialReconnectBackoffWindow func() time.Duration
// As the name suggests, we normally skip the "initial REconnect backoff"
// the very first time we try to connect. However, some callers instantiate
// new Connection objects after a disconnect, and they need the "first
Copy link

Choose a reason for hiding this comment

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

This is probably not mine to review, but IMO all reconnects should happen in this package, as opposed to making new rpc.Connection objects :-) Otherwise we might have redundant rpc.Connection lying around, and the redundant one might be trying to reconnect itself as well and continue with RPCs. We’ve had pretty stable reconnects for KBFS servers after moving the reconnect logic here.

Copy link
Author

Choose a reason for hiding this comment

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

You'll have to talk to @mmaxim about the problems he ran into with reconnect.

I kind of get the impression that someone's going to want to rewrite this entire class, and then salt the earth so that the original never grows again :)

Copy link

Choose a reason for hiding this comment

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

I kind of get the impression that someone's going to want to rewrite this entire class

Yeah I’ve had the impulse to do so a few times, but was afraid I was gonna introduce bugs or it would meet resistance so I ended up never trying 😅

@@ -336,7 +336,12 @@ type ConnectionOpts struct {
// InitialReconnectBackoffWindow, if non zero, causes a random backoff
// before reconnecting. The random backoff timer is fast-forward-able by
// passing in a WithFireNow(ctx) into a RPC call.
InitialReconnectBackoffWindow time.Duration
InitialReconnectBackoffWindow func() time.Duration
// As the name suggests, we normally skip the "initial REconnect backoff"
Copy link

Choose a reason for hiding this comment

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

I have a slight preference for an interface here which includes a GetReconnectBackoffWindow() method. But I'm OK with this too.

Please update the comment to reflect that this field is now a function.

The other thing is that I actually don't remember why this was named InitialReconnectBackOffWindow rather than ReconnectBackOffWindow. Maybe I planned to have it changeable, but that doesn't seem to be the case anymore, so the naming is a bit confusing now. So if you think the latter is better, feel free to change it!

@oconnor663 oconnor663 merged commit df335eb into master Dec 5, 2017
@oconnor663 oconnor663 deleted the jack/CORE-6527/backoff branch December 5, 2017 15:36
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.

None yet

3 participants