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
Conversation
rpc/connection.go
Outdated
@@ -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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/REconnect/reconnect
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
cc @songgao |
There was a problem hiding this 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.
rpc/connection.go
Outdated
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 😅
rpc/connection.go
Outdated
@@ -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" |
There was a problem hiding this comment.
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!
1a4a7d1
to
34c8b94
Compare
34c8b94
to
df335eb
Compare
These changes will allow client to back off of gregor reconnects, based on whether the current device is active in chat.
r? @mmaxim