Documentation ¶
Index ¶
- Variables
- func WithConnDatabase(name string) func(*conn)
- func WithConnID(v ConnID) func(*conn)
- func WithConnTracer(t tracer.Context) func(*conn)
- type Conn
- type ConnID
- type ConnManager
- func (cm *ConnManager) AddConn(c Conn) error
- func (cm *ConnManager) Close() error
- func (cm *ConnManager) Conns() []Conn
- func (cm *ConnManager) LookupConnByUID(cid uint64) (Conn, bool)
- func (cm *ConnManager) LookupConnByUUID(uuid uuid.UUID) (Conn, bool)
- func (cm *ConnManager) RemoveConn(conn Conn) error
- func (cm *ConnManager) RemoveConnByUID(cid uint64)
- func (cm *ConnManager) RemoveConnByUUID(uuid uuid.UUID)
- func (cm *ConnManager) Start() error
- func (cm *ConnManager) Stop() error
- func (cm *ConnManager) UpdateConn(from Conn, to Conn) error
- type ConnOption
Constants ¶
This section is empty.
Variables ¶
var ErrExist = errors.New("exist")
var ErrNotExist = errors.New("not exist")
Functions ¶
func WithConnDatabase ¶
func WithConnDatabase(name string) func(*conn)
WithConnDatabase sets a database name.
func WithConnTracer ¶
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 ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
ConnManager represents 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) UpdateConn ¶
func (cm *ConnManager) UpdateConn(from Conn, to Conn) error
UpdateConn updates the specified connection.