Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: client/swarming/swarming.go

Issue 1135173003: Create packages client/internal/ retry and lhttp. (Closed) Base URL: git@github.com:luci/luci-go@3_UI
Patch Set: . Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/swarming/swarming.go
diff --git a/client/swarming/swarming.go b/client/swarming/swarming.go
index 81c68cba34d2dd2473bb674da192265c793b3b86..19c7856627819844e7f5a1fb49be3bc5673b2244 100644
--- a/client/swarming/swarming.go
+++ b/client/swarming/swarming.go
@@ -10,7 +10,8 @@ import (
"strings"
"time"
- "github.com/luci/luci-go/client/internal/common"
+ "github.com/luci/luci-go/client/internal/lhttp"
+ "github.com/luci/luci-go/client/internal/retry"
)
// TaskID is a unique reference to a Swarming task.
@@ -18,25 +19,20 @@ type TaskID string
// Swarming defines a Swarming client.
type Swarming struct {
- host string
- client *http.Client
+ host string
}
func (s *Swarming) getJSON(resource string, v interface{}) error {
if len(resource) == 0 || resource[0] != '/' {
return errors.New("resource must start with '/'")
}
- status, err := common.GetJSON(s.client, s.host+resource, v)
- if status == http.StatusNotFound {
- return errors.New("not found")
- }
- return err
+ return lhttp.GetJSON(retry.Default, http.DefaultClient, s.host+resource, v)
}
// NewSwarming returns a new Swarming client.
func New(host string) (*Swarming, error) {
host = strings.TrimRight(host, "/")
- return &Swarming{host, http.DefaultClient}, nil
+ return &Swarming{host}, nil
}
// FetchRequest returns the TaskRequest.
« client/isolatedclient/isolatedclient.go ('K') | « client/isolatedclient/isolatedclient.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698