import (
"sync"
+
+ "git.arvados.org/arvados.git/sdk/go/arvados"
)
// A ClientPool is a pool of ArvadosClients. This is useful for
// credentials. See arvados-git-httpd for an example, and sync.Pool
// for more information about garbage collection.
type ClientPool struct {
- // Initialize new clients by coping this one.
+ // Initialize new clients by copying this one.
Prototype *ArvadosClient
pool *sync.Pool
// MakeClientPool returns a new empty ClientPool, using environment
// variables to initialize the prototype.
func MakeClientPool() *ClientPool {
- proto, err := MakeArvadosClient()
+ return MakeClientPoolWith(nil)
+}
+
+// MakeClientPoolWith returns a new empty ClientPool with a previously
+// initialized arvados.Client.
+func MakeClientPoolWith(client *arvados.Client) *ClientPool {
+ var err error
+ var proto *ArvadosClient
+
+ if client == nil {
+ proto, err = MakeArvadosClient()
+ } else {
+ proto, err = New(client)
+ }
return &ClientPool{
Prototype: proto,
lastErr: err,
"git.arvados.org/arvados.git/sdk/go/arvadosclient"
)
-// ClearCache clears the Keep service discovery cache.
+// RefreshServiceDiscovery clears the Keep service discovery cache.
func RefreshServiceDiscovery() {
var wg sync.WaitGroup
defer wg.Wait()
}
}
-// ClearCacheOnSIGHUP installs a signal handler that calls
-// ClearCache when SIGHUP is received.
+// RefreshServiceDiscoveryOnSIGHUP installs a signal handler that calls
+// RefreshServiceDiscovery when SIGHUP is received.
func RefreshServiceDiscoveryOnSIGHUP() {
svcListCacheMtx.Lock()
defer svcListCacheMtx.Unlock()
}
func (h *handler) setup() {
- h.clientPool = arvadosclient.MakeClientPool()
+ // Errors will be handled at the client pool.
+ arv, _ := arvados.NewClientFromConfig(h.Config.cluster)
+ h.clientPool = arvadosclient.MakeClientPoolWith(arv)
keepclient.RefreshServiceDiscoveryOnSIGHUP()
keepclient.DefaultBlockCache.MaxBlocks = h.Config.cluster.Collections.WebDAVCache.MaxBlockEntries