diff --git a/vendor/git.autistici.org/ai3/go-common/README.md b/vendor/git.autistici.org/ai3/go-common/README.md index 534838bfb168f391f01354ac1d74d976bd66489b..756a743b6f9008194e37d701fd4a23eb818fee6e 100644 --- a/vendor/git.autistici.org/ai3/go-common/README.md +++ b/vendor/git.autistici.org/ai3/go-common/README.md @@ -9,9 +9,13 @@ A quick overview of the contents: "RPC" implementation, just JSON POST requests but with retries, backoff, timeouts, tracing, etc. -* [server implementation of a line-based protocol over a UNIX socket](unix/) +* [server implementation of a generic line-based protocol over a UNIX + socket](unix/). -* a [LDAP connection pool](ldap/) +* a [LDAP connection pool](ldap/). + +* utilities to [serialize composite data types](ldap/compositetypes/) + used in our LDAP database. * a [password hashing library](pwhash/) that uses fancy advanced crypto by default but is also backwards compatible with old @@ -19,4 +23,3 @@ A quick overview of the contents: * utilities to [manage encryption keys](userenckey/), themselves encrypted with a password and a KDF. - diff --git a/vendor/git.autistici.org/ai3/go-common/clientutil/balancer.go b/vendor/git.autistici.org/ai3/go-common/clientutil/balancer.go index 84633ac271887a35a7575805f8a6633b983949af..d2ca8270fcf27deb3e48e3526a91bb2c8cf004a1 100644 --- a/vendor/git.autistici.org/ai3/go-common/clientutil/balancer.go +++ b/vendor/git.autistici.org/ai3/go-common/clientutil/balancer.go @@ -118,30 +118,31 @@ func (b *balancedBackend) Call(ctx context.Context, shard, path string, req, res // Call the backends in the sequence until one succeeds, with an // exponential backoff policy controlled by the outer Context. - var httpResp *http.Response - err = backoff.Retry(func() error { + return backoff.Retry(func() error { req, rerr := b.newJSONRequest(path, shard, data) if rerr != nil { return rerr } innerCtx, cancel := context.WithTimeout(ctx, innerTimeout) - httpResp, rerr = b.do(innerCtx, seq, req) - cancel() - return rerr - }, backoff.WithContext(newExponentialBackOff(), ctx)) - if err != nil { - return err - } - defer httpResp.Body.Close() // nolint + defer cancel() - // Decode the response. - if httpResp.Header.Get("Content-Type") != "application/json" { - return errors.New("not a JSON response") - } - if resp == nil { - return nil - } - return json.NewDecoder(httpResp.Body).Decode(resp) + // When do() returns successfully, we already know that the + // response had an HTTP status of 200. + httpResp, rerr := b.do(innerCtx, seq, req) + if rerr != nil { + return rerr + } + defer httpResp.Body.Close() // nolint + + // Decode the response, unless the 'resp' output is nil. + if httpResp.Header.Get("Content-Type") != "application/json" { + return errors.New("not a JSON response") + } + if resp == nil { + return nil + } + return json.NewDecoder(httpResp.Body).Decode(resp) + }, backoff.WithContext(newExponentialBackOff(), ctx)) } // Initialize a new target sequence. diff --git a/vendor/vendor.json b/vendor/vendor.json index a7b68d85d0e9f7db5e073b9b0a6a386d052f7431..5822d76e05e8866aa7260f4aee782551a32b8d4b 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -3,28 +3,28 @@ "ignore": "test", "package": [ { - "checksumSHA1": "mqNsLVty/oAcBDXv2DZeqMtGeaY=", + "checksumSHA1": "oUOxU+Tw1/jOzWVP05HuGvVSC/A=", "path": "git.autistici.org/ai3/go-common", - "revision": "0868f2647fefb9c3855bb6242aae8aab6d0ddc6d", - "revisionTime": "2019-01-29T12:17:45Z" + "revision": "54f0ac4c46184ae44486a31ca2705076abcc5321", + "revisionTime": "2019-06-30T08:30:15Z" }, { - "checksumSHA1": "hKJhn/0mTkaYIHwFTy+W9TLr09M=", + "checksumSHA1": "kJwm6y9JXhybelO2zUl7UbzIdP0=", "path": "git.autistici.org/ai3/go-common/clientutil", - "revision": "0868f2647fefb9c3855bb6242aae8aab6d0ddc6d", - "revisionTime": "2019-01-29T12:17:45Z" + "revision": "54f0ac4c46184ae44486a31ca2705076abcc5321", + "revisionTime": "2019-06-30T08:30:15Z" }, { "checksumSHA1": "TKGUNmKxj7KH3qhwiCh/6quUnwc=", "path": "git.autistici.org/ai3/go-common/serverutil", - "revision": "0868f2647fefb9c3855bb6242aae8aab6d0ddc6d", - "revisionTime": "2019-01-29T12:17:45Z" + "revision": "54f0ac4c46184ae44486a31ca2705076abcc5321", + "revisionTime": "2019-06-30T08:30:15Z" }, { "checksumSHA1": "y5pRYZ/NhfEOCFslPEuUZTYXcro=", "path": "git.autistici.org/ai3/go-common/tracing", - "revision": "0868f2647fefb9c3855bb6242aae8aab6d0ddc6d", - "revisionTime": "2019-01-29T12:17:45Z" + "revision": "54f0ac4c46184ae44486a31ca2705076abcc5321", + "revisionTime": "2019-06-30T08:30:15Z" }, { "checksumSHA1": "T9WPwUls+LPk89st6TGCbQf5HNQ=",