pool

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackoffDuration

type BackoffDuration interface {
	// Duration returns a duration that depends on the given attempt count.
	Duration(attempt int) time.Duration
}

BackoffDuration wraps Duration.

type GRPCClientConnBuilder

type GRPCClientConnBuilder struct {
	// DialTimeout specifies the timeout used when establishing a new
	// connection.
	DialTimeout time.Duration
	// Options is a set of grpc.DialOption to be used when creating a new
	// connection.
	Options []grpc.DialOption

	// TLSConfig is used to build transport credentials for the connection.
	// If not provided, insecure credentials are added to Options before creating
	// a new ClientConn.
	TLSConfig certloader.ClientConfigBuilder
}

GRPCClientConnBuilder is a generic ClientConnBuilder implementation.

func (GRPCClientConnBuilder) ClientConn

func (b GRPCClientConnBuilder) ClientConn(target, hostname string) (poolTypes.ClientConn, error)

ClientConn implements ClientConnBuilder.ClientConn.

type Option

type Option func(o *options) error

Option customizes the configuration of the Manager.

func WithBackoff

func WithBackoff(b BackoffDuration) Option

WithBackoff sets the backoff between after a failed connection attempt.

func WithClientConnBuilder

func WithClientConnBuilder(b poolTypes.ClientConnBuilder) Option

WithClientConnBuilder sets the GRPCClientConnBuilder that is used to create new gRPC connections to peers.

func WithConnCheckInterval

func WithConnCheckInterval(i time.Duration) Option

WithConnCheckInterval sets the time interval between peer connections health checks.

func WithConnStatusInterval added in v1.15.0

func WithConnStatusInterval(i time.Duration) Option

WithConnStatusInterval sets the time interval between peer connection status is reported through Prometheus gauge metrics.

func WithLogger

func WithLogger(l logrus.FieldLogger) Option

WithLogger sets the logger to use for logging.

func WithPeerClientBuilder

func WithPeerClientBuilder(b peerTypes.ClientBuilder) Option

WithPeerClientBuilder sets the ClientBuilder that is used to create new Peer service clients.

func WithPeerServiceAddress

func WithPeerServiceAddress(a string) Option

WithPeerServiceAddress sets the address of the peer gRPC service.

func WithRetryTimeout

func WithRetryTimeout(t time.Duration) Option

WithRetryTimeout sets the duration to wait before attempting to re-connect to the peer gRPC service.

type PeerManager

type PeerManager struct {
	// contains filtered or unexported fields
}

PeerManager manages a pool of peers (Peer) and associated gRPC connections. Peers and peer change notifications are obtained from a peer gRPC service.

func NewPeerManager

func NewPeerManager(registry prometheus.Registerer, options ...Option) (*PeerManager, error)

NewPeerManager creates a new manager that connects to a peer gRPC service to manage peers and a connection to every peer's gRPC API.

func (*PeerManager) List

func (m *PeerManager) List() []poolTypes.Peer

List implements observer.PeerLister.List.

func (*PeerManager) Start

func (m *PeerManager) Start()

Start starts the manager.

func (*PeerManager) Status added in v1.15.0

func (m *PeerManager) Status() Status

Status provides the status of the manager

func (*PeerManager) Stop

func (m *PeerManager) Stop()

Stop stops the manager.

type PoolMetrics added in v1.15.0

type PoolMetrics struct {
	PeerConnStatus *prometheus.GaugeVec
	// contains filtered or unexported fields
}

PoolMetrics holds metrics related to the scope of this package.

func NewPoolMetrics added in v1.15.0

func NewPoolMetrics(registry prometheus.Registerer) *PoolMetrics

NewPoolMetrics creates a new PoolMetrics object.

func (*PoolMetrics) ObservePeerConnectionStatus added in v1.15.0

func (m *PoolMetrics) ObservePeerConnectionStatus(peerConnStatus map[connectivity.State]uint32, nilConnNum uint32)

ObservePeerConnectionStatus sets the value of PeerConnStatus gauge metric family. This method is thread-safe.

type Status added in v1.15.0

type Status struct {
	PeerServiceConnected bool
	AvailablePeers       int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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