internal

package
v2.16.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 29, 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

NewConnection creates a new 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

LocalAddr implements net.Conn.LocalAddr().

func (*Connection) Read

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

Read implements net.Conn.Read().

func (*Connection) RemoteAddr

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

RemoteAddr implements net.Conn.RemoteAddr().

func (*Connection) Reusable

func (v *Connection) Reusable() bool

Reusable implements internet.Reusable.Reusable().

func (*Connection) SetDeadline

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

SetDeadline implements net.Conn.SetDeadline().

func (*Connection) SetReadDeadline

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

SetReadDeadline implements net.Conn.SetReadDeadline().

func (*Connection) SetReusable

func (v *Connection) SetReusable(reusable bool)

SetReusable implements internet.Reusable.SetReusable().

func (*Connection) SetWriteDeadline

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

SetWriteDeadline implements net.Conn.SetWriteDeadline().

func (*Connection) SysFd

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

SysFd implement internet.SysFd.SysFd().

func (*Connection) Write

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

Write implement net.Conn.Write().

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 NoOpConnectionRecyler

type NoOpConnectionRecyler struct{}

func (NoOpConnectionRecyler) Put

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
}

Reuser determines whether a connection can be reused or not.

func ReuseConnection

func ReuseConnection(reuse bool) *Reuser

ReuseConnection returns a tracker for tracking connection reusability.

Jump to

Keyboard shortcuts

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