Merge branch 'master' into 16950-add-costanalyzer
[arvados.git] / sdk / go / keepclient / support.go
index f4e99bdbe3ef8c699d1bd7aadf97a861f5950b1d..91117f2d3216ea317b05761b155a42e9e00f2da6 100644 (file)
@@ -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!