net

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExist = errors.New("exist")
View Source
var ErrNotExist = errors.New("not exist")

Functions

func WithConnDatabase

func WithConnDatabase(name string) func(*conn)

WithConnDatabase sets a database name.

func WithConnID

func WithConnID(v ConnID) func(*conn)

WithConnID sets a connection ID.

func WithConnTracer

func WithConnTracer(t tracer.Context) func(*conn)

WithConnTracer sets a tracer context.

Types

type Conn

type Conn interface {
	tracer.Context
	// Context returns the context.
	Context() context.Context
	// RemoteAddr returns the remote address.
	RemoteAddr() net.Addr
	// Close closes the connection.
	Close() error
	// SetDatabase sets a database name.
	SetDatabase(db string)
	// Database returns the database name.
	Database() string
	// Timestamp returns the timestamp.
	Timestamp() time.Time
	// UUID returns the UUID.
	UUID() uuid.UUID
	// ID returns the ID.
	ID() ConnID
	// SetSpanContext sets a span context.
	SetSpanContext(ctx tracer.Context)
	// SpanContext returns a span context.
	SpanContext() tracer.Context
}

Conn represents a connection.

func NewConnWith

func NewConnWith(netConn net.Conn, opts ...ConnOption) Conn

NewConnWith returns a connection with a raw connection.

type ConnID

type ConnID = uint64

ConnID represents a connection ID.

type ConnManager

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

ConnManager represents a connection map.

func NewConnManager

func NewConnManager() *ConnManager

NewConnManager returns a connection map.

func (*ConnManager) AddConn

func (cm *ConnManager) AddConn(c Conn) error

AddConn adds the specified connection.

func (*ConnManager) Close

func (cm *ConnManager) Close() error

Close closes the connection manager.

func (*ConnManager) Conns

func (cm *ConnManager) Conns() []Conn

Conns returns the included connections.

func (*ConnManager) LookupConnByUID

func (cm *ConnManager) LookupConnByUID(cid uint64) (Conn, bool)

LookupConnByUID returns a connection and true when the specified connection exists by the connection ID, otherwise nil and false.

func (*ConnManager) LookupConnByUUID

func (cm *ConnManager) LookupConnByUUID(uuid uuid.UUID) (Conn, bool)

LookupConnByUUID returns the connection with the specified UUID.

func (*ConnManager) RemoveConn

func (cm *ConnManager) RemoveConn(conn Conn) error

RemoveConn deletes the specified connection from the map.

func (*ConnManager) RemoveConnByUID

func (cm *ConnManager) RemoveConnByUID(cid uint64)

RemoveConnByUID deletes the specified connection by the connection ID.

func (*ConnManager) RemoveConnByUUID

func (cm *ConnManager) RemoveConnByUUID(uuid uuid.UUID)

RemoveConnByUID deletes the specified connection by the connection ID.

func (*ConnManager) Start

func (cm *ConnManager) Start() error

Start starts the connection manager.

func (*ConnManager) Stop

func (cm *ConnManager) Stop() error

Stop closes all connections.

func (*ConnManager) UpdateConn

func (cm *ConnManager) UpdateConn(from Conn, to Conn) error

UpdateConn updates the specified connection.

type ConnOption

type ConnOption = func(*conn)

ConnOption represents a connection option.

Jump to

Keyboard shortcuts

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