internal

package
v2.13.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSysFd

func GetSysFd(conn net.Conn) (int, error)

GetSysFd returns the underlying fd of a connection.

Types

type Connection

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

Connection is an implementation of net.Conn with re-usability.

func NewConnection

func NewConnection(id ConnectionID, conn net.Conn, manager ConnectionRecyler, reuser *Reuser) *Connection

func (*Connection) Close

func (v *Connection) Close() error

Close implements net.Conn.Close(). If the connection is reusable, the underlying connection will be recycled.

func (*Connection) LocalAddr

func (v *Connection) LocalAddr() net.Addr

func (*Connection) Read

func (v *Connection) Read(b []byte) (int, error)

func (*Connection) RemoteAddr

func (v *Connection) RemoteAddr() net.Addr

func (*Connection) Reusable

func (v *Connection) Reusable() bool

func (*Connection) SetDeadline

func (v *Connection) SetDeadline(t time.Time) error

func (*Connection) SetReadDeadline

func (v *Connection) SetReadDeadline(t time.Time) error

func (*Connection) SetReusable

func (v *Connection) SetReusable(reusable bool)

func (*Connection) SetWriteDeadline

func (v *Connection) SetWriteDeadline(t time.Time) error

func (*Connection) SysFd

func (v *Connection) SysFd() (int, error)

func (*Connection) Write

func (v *Connection) Write(b []byte) (int, error)

type ConnectionID

type ConnectionID struct {
	Local      v2net.Address
	Remote     v2net.Address
	RemotePort v2net.Port
}

ConnectionID is the ID of a connection.

func NewConnectionID

func NewConnectionID(source v2net.Address, dest v2net.Destination) ConnectionID

NewConnectionID creates a new ConnectionId.

type ConnectionRecyler

type ConnectionRecyler interface {
	// Put returns a connection back to a connection pool.
	Put(ConnectionID, net.Conn)
}

ConnectionRecyler is the interface for recycling connections.

type ExpiringConnection

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

ExpiringConnection is a connection that will expire in certain time.

func (*ExpiringConnection) Expired

func (ec *ExpiringConnection) Expired() bool

Expired returns true if the connection has expired.

type Pool

type Pool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Pool is a connection pool.

func NewConnectionPool

func NewConnectionPool() *Pool

NewConnectionPool creates a new Pool.

func (*Pool) Get

func (p *Pool) Get(id ConnectionID) net.Conn

Get returns a connection with matching connection ID. Nil if not found.

func (*Pool) Put

func (p *Pool) Put(id ConnectionID, conn net.Conn)

Put implements ConnectionRecyler.Put().

type Reuser

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

func ReuseConnection

func ReuseConnection(reuse bool) *Reuser

Jump to

Keyboard shortcuts

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