Documentation ¶
Index ¶
- type Pool
- func (p *Pool) Count() int
- func (p *Pool) GetClientFor(addr string) (PoolClient, error)
- func (p *Pool) GetClientForInstance(inst ring.InstanceDesc) (PoolClient, error)
- func (p *Pool) RegisteredAddresses() []string
- func (p *Pool) RemoveClient(client PoolClient, addr string)
- func (p *Pool) RemoveClientFor(addr string)
- type PoolAddrFunc
- type PoolClient
- type PoolConfig
- type PoolFactory
- type PoolInstFunc
- type PoolServiceDiscovery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
Pool holds a cache of grpc_health_v1 clients.
func NewPool ¶
func NewPool(clientName string, cfg PoolConfig, discovery PoolServiceDiscovery, factory PoolFactory, clientsMetric prometheus.Gauge, logger log.Logger) *Pool
NewPool creates a new Pool.
func (*Pool) GetClientFor ¶
func (p *Pool) GetClientFor(addr string) (PoolClient, error)
GetClientFor gets the client for the specified address. If it does not exist it will make a new client for that address.
func (*Pool) GetClientForInstance ¶
func (p *Pool) GetClientForInstance(inst ring.InstanceDesc) (PoolClient, error)
GetClientForInstance gets the client for the specified ring member. If it does not exist it will make a new client for that instance.
func (*Pool) RegisteredAddresses ¶
RegisteredAddresses returns all the service addresses for which there's an active client.
func (*Pool) RemoveClient ¶
func (p *Pool) RemoveClient(client PoolClient, addr string)
RemoveClient removes the client instance from the pool if it is still there and not cleaned up by health check. The value of client needs to be the same as returned by GetClientForInstance or GetClientFor. If addr is not empty and contains the same addr passed when obtaining the client, then the operation is sped up.
func (*Pool) RemoveClientFor ¶
RemoveClientFor removes the client with the specified address
type PoolAddrFunc ¶
type PoolAddrFunc func(addr string) (PoolClient, error)
PoolAddrFunc is an implementation of PoolFactory for functions that accept an instance address.
func (PoolAddrFunc) FromInstance ¶
func (f PoolAddrFunc) FromInstance(inst ring.InstanceDesc) (PoolClient, error)
type PoolClient ¶
type PoolClient interface { grpc_health_v1.HealthClient io.Closer }
PoolClient is the interface that should be implemented by a client managed by the pool.
type PoolConfig ¶
type PoolConfig struct { CheckInterval time.Duration HealthCheckEnabled bool HealthCheckTimeout time.Duration MaxConcurrentHealthChecks int // defaults to 16 }
PoolConfig is config for creating a Pool.
type PoolFactory ¶
type PoolFactory interface {
FromInstance(inst ring.InstanceDesc) (PoolClient, error)
}
PoolFactory is the interface for creating new clients based on the description of an instance in the ring.
type PoolInstFunc ¶
type PoolInstFunc func(inst ring.InstanceDesc) (PoolClient, error)
PoolInstFunc is an implementation of PoolFactory for functions that accept ring instance metadata.
func (PoolInstFunc) FromInstance ¶
func (f PoolInstFunc) FromInstance(inst ring.InstanceDesc) (PoolClient, error)
type PoolServiceDiscovery ¶
PoolServiceDiscovery defines the signature of a function returning the list of known service endpoints. This function is used to remove stale clients from the pool (a stale client is a client connected to a service endpoint no more active).
func NewRingServiceDiscovery ¶
func NewRingServiceDiscovery(r ring.ReadRing) PoolServiceDiscovery