connpool

package
v0.0.0-...-6260e1a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseConn

func CloseConn(conn gnet.Conn, after time.Duration)

CloseConn closes a connection after a duration of time

Types

type Dialer

type Dialer interface {
	Dial(addr string) (gnet.Conn, error)
}

Dialer is the interface of a dialer that return a NetConn

type EndpointRestrictedConnPool

type EndpointRestrictedConnPool interface {
	Get() (gnet.Conn, error)
	Put(conn gnet.Conn, err error)
	UpdateEndpoints(all, add, del []string)
	NumPooled() int
}

EndpointRestrictedConnPool is the interface of a simple endpoint restricted connection pool that the connection's remote address must be in an endpoint list, if not, it will be closed and can not be used anymore, it is useful for holding the connections to a service whose endpoints can be changed at runtime.

func NewConnPool

func NewConnPool(initEndpoints []string, connsPerEndpoint, size int,
	dialer Dialer, log logger.Logger) (EndpointRestrictedConnPool, error)

NewConnPool news a EndpointRestrictedConnPool

Jump to

Keyboard shortcuts

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