conn

package
v0.0.0-...-e603270 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoConnection indicates no connection exists to a node.
	ErrNoConnection = errors.New("No connection exists")
	// ErrUnhealthyConnection indicates the connection to a node is unhealthy.
	ErrUnhealthyConnection = errors.New("Unhealthy connection")
	//EchoDuration           = 500 * time.Millisecond
	EchoDuration = 2 * time.Second
)

Functions

This section is empty.

Types

type Pool

type Pool struct {
	sync.RWMutex

	Addr string
	// contains filtered or unexported fields
}

Pool is used to manage the grpc client connection(s) for communicating with other worker instances. Right now it just holds one of them.

func (*Pool) Get

func (p *Pool) Get() *grpc.ClientConn

Get returns the connection to use from the pool of connections.

func (*Pool) IsHealthy

func (p *Pool) IsHealthy() bool

IsHealthy returns whether the pool is healthy.

func (*Pool) LastEcho

func (p *Pool) LastEcho() time.Time

func (*Pool) MonitorHealth

func (p *Pool) MonitorHealth()

MonitorHealth monitors the health of the connection via Echo. This function blocks forever.

func (*Pool) SetUnhealthy

func (p *Pool) SetUnhealthy()

SetUnhealthy marks a pool as unhealthy.

type Pools

type Pools struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Pools manages a concurrency-safe set of Pool.

func GetPools

func GetPools() *Pools

GetPools returns the list of pools.

func (*Pools) Connect

func (p *Pools) Connect(addr string) *Pool

Connect creates a Pool instance for the node with the given address or returns the existing one.

func (*Pools) Get

func (p *Pools) Get(addr string) (*Pool, error)

Get returns the list for the given address.

Jump to

Keyboard shortcuts

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