api: API connection monitoring improvements #6398

Merged
merged 10 commits into from Oct 7, 2016

Conversation

Projects
None yet
3 participants
Contributor

mjs commented Oct 7, 2016

The core change here is that an api.Connection's underlying rpc.Conn's Dead channel is now monitored. This means that a broken connection is now noticed much sooner than waiting for the next connection ping (pings are still used as a fallback however).

Other improvements were made along the way:

  • the connection monitoring logic was extracted into its own type and file
  • connection monitoring now has tests (completely untested before)
  • PingPeriod and PingTimeout are now consts
  • PingTimeout is no longer unnecessarily exported

mjs added some commits Oct 6, 2016

api: Extract connection monitoring
... and added missing test coverage.

Also fixed handling of the `closed` channel being closed. Another ping
was being unnecessarily attempted in this case.
api: Rearrange pings so they happen after timeout
There's no need to ping just after the connection comes up, especially
with the upcoming dead monitoring in place.
api: waitThenAdvance helper
Reduces test boilerplate.
api: Connection dies when underlying rpc.Conn dies
Instead of relying solely on pings, api.Connection will now also die
early if the underlying rpc.Conn's Dead channel is closed. This allows
dead connections to be noticed much more quickly.
api: monitor now takes ping durations as args
... rather than using global constants
api: PingTimeout is no longer exported
It should be exported and doesn't need to be.

Nice

api/apiclient.go
@@ -453,6 +460,10 @@ func (st *state) apiEndpoint(path, query string) (*url.URL, error) {
}, nil
}
+func (s *state) Ping() error {
@mjs

mjs Oct 7, 2016

Contributor

It was pre-existing (I only moved it). I suspect it doesn't need to be exported so I'l aim for that.

Contributor

mjs commented Oct 7, 2016

$$merge$$

Contributor

jujubot commented Oct 7, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit d7da116 into juju:master Oct 7, 2016

@mjs mjs deleted the mjs:apiclient-dead-detection branch Oct 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment