X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d356f441d55dfdc26a0ec3f1db344923b1e9b79d..6bf9e1a4b5640f3cdd057810f0c9b8a945bb88bd:/sdk/go/keepclient/support.go diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go index 594379b4fa..91117f2d32 100644 --- a/sdk/go/keepclient/support.go +++ b/sdk/go/keepclient/support.go @@ -18,7 +18,7 @@ import ( "git.arvados.org/arvados.git/sdk/go/arvadosclient" ) -// Function used to emit debug messages. The easiest way to enable +// DebugPrintf emits debug messages. The easiest way to enable // keepclient debug messages in your application is to assign // log.Printf to DebugPrintf. var DebugPrintf = func(string, ...interface{}) {} @@ -79,7 +79,7 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea req.Header.Add("X-Request-Id", reqid) req.Header.Add("Authorization", "OAuth2 "+this.Arvados.ApiToken) req.Header.Add("Content-Type", "application/octet-stream") - req.Header.Add(X_Keep_Desired_Replicas, fmt.Sprint(this.Want_replicas)) + req.Header.Add(XKeepDesiredReplicas, fmt.Sprint(this.Want_replicas)) if len(this.StorageClasses) > 0 { req.Header.Add("X-Keep-Storage-Classes", strings.Join(this.StorageClasses, ", ")) } @@ -92,7 +92,7 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea } rep := 1 - if xr := resp.Header.Get(X_Keep_Replicas_Stored); xr != "" { + if xr := resp.Header.Get(XKeepReplicasStored); xr != "" { fmt.Sscanf(xr, "%d", &rep) } @@ -161,7 +161,7 @@ func (this *KeepClient) putReplicas( lastError := make(map[string]string) for retriesRemaining > 0 { - retriesRemaining -= 1 + retriesRemaining-- nextServer = 0 retryServers = []string{} for replicasTodo > 0 { @@ -170,8 +170,8 @@ func (this *KeepClient) putReplicas( if nextServer < len(sv) { DebugPrintf("DEBUG: [%s] Begin upload %s to %s", reqid, hash, sv[nextServer]) go this.uploadToKeepServer(sv[nextServer], hash, getReader(), uploadStatusChan, expectedLength, reqid) - nextServer += 1 - active += 1 + nextServer++ + active++ } else { if active == 0 && retriesRemaining == 0 { msg := "Could not write sufficient replicas: " @@ -190,7 +190,7 @@ func (this *KeepClient) putReplicas( // Now wait for something to happen. if active > 0 { status := <-uploadStatusChan - active -= 1 + active-- if status.statusCode == 200 { // good news!