7 // A ClientPool is a pool of ArvadosClients. This is useful for
8 // applications that make API calls using a dynamic set of tokens,
9 // like web services that pass through their own clients'
10 // credentials. See arvados-git-httpd for an example, and sync.Pool
11 // for more information about garbage collection.
12 type ClientPool struct {
17 // MakeClientPool returns a new empty ClientPool.
18 func MakeClientPool() *ClientPool {
20 p.Pool = sync.Pool{New: func() interface{} {
21 arv, err := MakeArvadosClient()
31 // Err returns the error that was encountered last time Get returned
33 func (p *ClientPool) Err() error {
37 // Get returns an ArvadosClient taken from the pool, or a new one if
38 // the pool is empty. If an existing client is returned, its state
39 // (including its ApiToken) will be just as it was when it was Put
41 func (p *ClientPool) Get() *ArvadosClient {
42 c, ok := p.Pool.Get().(*ArvadosClient)
49 // Put puts an ArvadosClient back in the pool.
50 func (p *ClientPool) Put(c *ArvadosClient) {