Commit 2b0dc1aa authored by ale's avatar ale

Update go-common/clientutil

parent 070500a9
Pipeline #3656 passed with stages
in 2 minutes and 20 seconds
......@@ -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.
......@@ -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.
......
......@@ -3,46 +3,46 @@
"ignore": "test",
"package": [
{
"checksumSHA1": "mqNsLVty/oAcBDXv2DZeqMtGeaY=",
"checksumSHA1": "oUOxU+Tw1/jOzWVP05HuGvVSC/A=",
"path": "git.autistici.org/ai3/go-common",
"revision": "2934fd63c275d37b0fe60afabb484a251662bd49",
"revisionTime": "2019-02-17T09:01:06Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "hKJhn/0mTkaYIHwFTy+W9TLr09M=",
"checksumSHA1": "kJwm6y9JXhybelO2zUl7UbzIdP0=",
"path": "git.autistici.org/ai3/go-common/clientutil",
"revision": "2934fd63c275d37b0fe60afabb484a251662bd49",
"revisionTime": "2019-02-17T09:01:06Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "d8aQcSXveyjPfFJgfB8NnM+x8dg=",
"path": "git.autistici.org/ai3/go-common/ldap",
"revision": "2934fd63c275d37b0fe60afabb484a251662bd49",
"revisionTime": "2019-02-17T09:01:06Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "ETt1H7ZXeT+mOGVuWDvgGBVx98k=",
"path": "git.autistici.org/ai3/go-common/ldap/compositetypes",
"revision": "95125bd587550f8f2ae1e7c412bb0ef94671f014",
"revisionTime": "2019-03-27T08:48:39Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "JcfbQfBD7HTqjhFYT1gBjbThSI4=",
"checksumSHA1": "1TsCGuI5907zG+voDXDpZ9I+H8E=",
"path": "git.autistici.org/ai3/go-common/pwhash",
"revision": "b4364e842290fdecd412056674b471af77663757",
"revisionTime": "2019-04-03T06:59:52Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "y5pRYZ/NhfEOCFslPEuUZTYXcro=",
"path": "git.autistici.org/ai3/go-common/tracing",
"revision": "2934fd63c275d37b0fe60afabb484a251662bd49",
"revisionTime": "2019-02-17T09:01:06Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "jRc0JfRUtCr3xxkgwRDVppsSnl0=",
"path": "git.autistici.org/ai3/go-common/unix",
"revision": "b4364e842290fdecd412056674b471af77663757",
"revisionTime": "2019-04-03T06:59:52Z"
"revision": "54f0ac4c46184ae44486a31ca2705076abcc5321",
"revisionTime": "2019-06-30T08:30:15Z"
},
{
"checksumSHA1": "J0QeD9LVccFOejgPKa0td8JD0rY=",
......@@ -96,8 +96,8 @@
"checksumSHA1": "2nTxrtvUecg8v33ZkjIFiUxfUI8=",
"origin": "git.autistici.org/id/usermetadb/vendor/github.com/cenkalti/backoff",
"path": "github.com/cenkalti/backoff",
"revision": "fa081ac5509ba4ed97ab6a447d611c1adcf9e764",
"revisionTime": "2018-11-03T07:16:06Z"
"revision": "d5fd9a28ed3b31c873fdaf4a6d9d153c767241d1",
"revisionTime": "2019-06-10T07:40:23Z"
},
{
"checksumSHA1": "zg16zjZTQ9R89+UOLmEZxHgxDtM=",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment