X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7d5d57a522489209e6b3cecfef94bab0aae4a7f5..e56ae6aad06c37d5512537047871d7363dd97620:/sdk/go/keepclient/discover.go diff --git a/sdk/go/keepclient/discover.go b/sdk/go/keepclient/discover.go index f039c21810..f3e3960698 100644 --- a/sdk/go/keepclient/discover.go +++ b/sdk/go/keepclient/discover.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "log" + "net/http" "os" "os/signal" "reflect" @@ -12,16 +13,34 @@ import ( "time" ) -// DiscoverKeepServers gets list of available keep services from api server +// DiscoverKeepServers gets list of available keep services from the +// API server. +// +// If a list of services is provided in the arvadosclient (e.g., from +// an environment variable or local config), that list is used +// instead. func (this *KeepClient) DiscoverKeepServers() error { - var list svcList + if this.Arvados.KeepServiceURIs != nil { + this.foundNonDiskSvc = true + this.replicasPerService = 0 + if c, ok := this.Client.(*http.Client); ok { + this.setClientSettingsNonDisk(c) + } + roots := make(map[string]string) + for i, uri := range this.Arvados.KeepServiceURIs { + roots[fmt.Sprintf("00000-bi6l4-%015d", i)] = uri + } + this.SetServiceRoots(roots, roots, roots) + return nil + } - // Get keep services from api server + // ArvadosClient did not provide a services list. Ask API + // server for a list of accessible services. + var list svcList err := this.Arvados.Call("GET", "keep_services", "", "accessible", nil, &list) if err != nil { return err } - return this.loadKeepServers(list) } @@ -118,10 +137,12 @@ func (this *KeepClient) loadKeepServers(list svcList) error { gatewayRoots[service.Uuid] = url } - if this.foundNonDiskSvc { - this.setClientSettingsNonDisk() - } else { - this.setClientSettingsDisk() + if client, ok := this.Client.(*http.Client); ok { + if this.foundNonDiskSvc { + this.setClientSettingsNonDisk(client) + } else { + this.setClientSettingsDisk(client) + } } this.SetServiceRoots(localRoots, writableLocalRoots, gatewayRoots)