pool

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CName = "common.net.pool"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool interface {
	// Get lookups to peer in existing connections or creates and outgoing new one
	Get(ctx context.Context, id string) (peer.Peer, error)
	// GetOneOf searches at least one existing connection in outgoing or creates a new one from a randomly selected id from given list
	GetOneOf(ctx context.Context, peerIds []string) (peer.Peer, error)
	// AddPeer adds incoming peer to the pool. The pool tracks peers by
	// instance; an implementation that is not comparable (not a pointer) is
	// kept behind a pointer of the pool's own, so it behaves the same
	AddPeer(ctx context.Context, p peer.Peer) (err error)
	// Pick checks if a connection with the peer exists, without dialing.
	// For a peer whose last dial failed it returns the cached dial error.
	Pick(ctx context.Context, id string) (pr peer.Peer, err error)
	// Flush invalidates every pooled connection and every dial in flight: it
	// swaps in an empty pool, reports Closed for each pooled peer before it
	// returns and tears the old connections down in the background. Later
	// lookups redial. Callers should coalesce their triggers, since each
	// Flush cancels the dials of the one before.
	Flush(ctx context.Context) error
}

Pool creates and caches outgoing connection

type Service

type Service interface {
	Pool
	app.ComponentRunnable
}

func New

func New() Service

Directories

Path Synopsis
Package mock_pool is a generated GoMock package.
Package mock_pool is a generated GoMock package.

Jump to

Keyboard shortcuts

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