Documentation ¶
Overview ¶
Package connectionpool functions as a connection cache that takes care of connecting and reusing connected sockets. it also makes sure we don't have duplicate connections.
Index ¶
- type ConnectionPool
- func (cp *ConnectionPool) CloseConnection(key p2pcrypto.PublicKey)
- func (cp *ConnectionPool) GetConnection(ctx context.Context, address inet.Addr, remotePub p2pcrypto.PublicKey) (net.Connection, error)
- func (cp *ConnectionPool) GetConnectionIfExists(remotePub p2pcrypto.PublicKey) (net.Connection, error)
- func (cp *ConnectionPool) OnClosedConnection(ctx context.Context, cwe net.ConnectionWithErr)
- func (cp *ConnectionPool) OnNewConnection(ctx context.Context, nce net.NewConnectionEvent) error
- func (cp *ConnectionPool) Shutdown()
- type DialFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool stores all net.Connections and make them available to all users of net.Connection. There are two sources of connections - - Local connections that were created by local node (by calling GetConnection) - Remote connections that were provided by a networker impl. in a pub-sub manner
func NewConnectionPool ¶
NewConnectionPool creates new ConnectionPool
func (*ConnectionPool) CloseConnection ¶
func (cp *ConnectionPool) CloseConnection(key p2pcrypto.PublicKey)
CloseConnection closes a connection and removes it from the pool.
func (*ConnectionPool) GetConnection ¶
func (cp *ConnectionPool) GetConnection(ctx context.Context, address inet.Addr, remotePub p2pcrypto.PublicKey) (net.Connection, error)
GetConnection fetches or creates if don't exist a connection to the address which is associated with the remote public key
func (*ConnectionPool) GetConnectionIfExists ¶
func (cp *ConnectionPool) GetConnectionIfExists(remotePub p2pcrypto.PublicKey) (net.Connection, error)
GetConnectionIfExists checks if the connection is exists or pending
func (*ConnectionPool) OnClosedConnection ¶
func (cp *ConnectionPool) OnClosedConnection(ctx context.Context, cwe net.ConnectionWithErr)
OnClosedConnection is an exported method used to handle new closing connections events
func (*ConnectionPool) OnNewConnection ¶
func (cp *ConnectionPool) OnNewConnection(ctx context.Context, nce net.NewConnectionEvent) error
OnNewConnection is an exported method used to handle new connection events
func (*ConnectionPool) Shutdown ¶
func (cp *ConnectionPool) Shutdown()
Shutdown gracefully shuts down the ConnectionPool: - Closes all open connections - Waits for all Dial routines to complete and unblock any routines waiting for GetConnection