Documentation ¶
Index ¶
- func GetSysFd(conn net.Conn) (int, error)
- type Connection
- func (v *Connection) Close() error
- func (v *Connection) LocalAddr() net.Addr
- func (v *Connection) Read(b []byte) (int, error)
- func (v *Connection) RemoteAddr() net.Addr
- func (v *Connection) Reusable() bool
- func (v *Connection) SetDeadline(t time.Time) error
- func (v *Connection) SetReadDeadline(t time.Time) error
- func (v *Connection) SetReusable(reusable bool)
- func (v *Connection) SetWriteDeadline(t time.Time) error
- func (v *Connection) SysFd() (int, error)
- func (v *Connection) Write(b []byte) (int, error)
- type ConnectionID
- type ConnectionRecyler
- type ExpiringConnection
- type NoOpConnectionRecyler
- type Pool
- type Reuser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connection ¶
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().
type ConnectionID ¶
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 ¶
func (NoOpConnectionRecyler) Put(ConnectionID, net.Conn)