MCPcopy
hub / github.com/dropbox/godropbox / GetInstancePool

Method GetInstancePool

net2/http2/load_balanced_pool.go:429–438  ·  view source on GitHub ↗

Returns a SimplePool for given instanceId, or an error if it does not exist. TODO(zviad): right now this scans all instances, thus if there are a lot of instances per partition it can become very slow. If it becomes a problem, fix it!

(instanceId int)

Source from the content-addressed store, hash-verified

427// TODO(zviad): right now this scans all instances, thus if there are a lot of
428// instances per partition it can become very slow. If it becomes a problem, fix it!
429func (pool *LoadBalancedPool) GetInstancePool(instanceId int) (*SimplePool, error) {
430 pool.lock.RLock()
431 defer pool.lock.RUnlock()
432 for _, instancePool := range pool.instanceList {
433 if instancePool.instanceId == instanceId {
434 return &instancePool.SimplePool, nil
435 }
436 }
437 return nil, errors.Newf("InstanceId: %v not found in the pool", instanceId)
438}
439
440// Marks instance down till downUntil epoch in seconds.
441func (pool *LoadBalancedPool) markInstanceDown(

Callers 1

TestRetriesMethod · 0.95

Calls 3

NewfFunction · 0.92
RLockMethod · 0.65
RUnlockMethod · 0.65

Tested by 1

TestRetriesMethod · 0.76