client

package
v1.3.0-rc.1.0...-65594da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	services.Service

	sync.RWMutex
	// contains filtered or unexported fields
}

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) Count

func (p *Pool) Count() int

Count returns how many clients are in the cache

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 at that address

func (*Pool) RegisteredAddresses

func (p *Pool) RegisteredAddresses() []string

RegisteredAddresses returns all the service addresses for which there's an active client.

func (*Pool) RemoveClientFor

func (p *Pool) RemoveClientFor(addr string)

RemoveClientFor removes the client with the specified address

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
}

PoolConfig is config for creating a Pool.

type PoolFactory

type PoolFactory func(addr string) (PoolClient, error)

PoolFactory defines the signature for a client factory.

type PoolServiceDiscovery

type PoolServiceDiscovery func() ([]string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL