X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/16f704326f44fd1e5e5e60b936c9b5895d6a6ff8..b91b5feb69b0939c99e4d71728c345ca98f5cc92:/sdk/go/arvadosclient/pool.go diff --git a/sdk/go/arvadosclient/pool.go b/sdk/go/arvadosclient/pool.go index 732080770b..bb7867aef7 100644 --- a/sdk/go/arvadosclient/pool.go +++ b/sdk/go/arvadosclient/pool.go @@ -6,6 +6,8 @@ package arvadosclient import ( "sync" + + "git.arvados.org/arvados.git/sdk/go/arvados" ) // A ClientPool is a pool of ArvadosClients. This is useful for @@ -14,7 +16,7 @@ import ( // 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 @@ -25,7 +27,20 @@ type ClientPool struct { // 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,