stringmux

package
v4.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringMuxByte  uint8 = 0b11001000
	MaxLenStreamID int   = 0xFF
)
View Source
const DefaultMTU uint32 = 8192

Variables

View Source
var (
	ErrConnAlreadyExists = errors.New("connection already exists")
	ErrConnNotFound      = errors.New("connection not found")
)
View Source
var (
	ErrStreamIDTooLarge = errors.New("stream id too large")
	ErrInvalidHeader    = errors.New("invalid first byte")
)

Functions

func Marshal

func Marshal(streamID string, data []byte) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte) (string, []byte, error)

Types

type Conn

type Conn interface {
	net.Conn
	CloseWrite()
	StreamID() string
	Done() <-chan struct{}
}

type Params

type Params struct {
	Log            logger.Logger
	Conn           net.Conn
	MTU            uint32
	ReadChanSize   int
	ReadBufferSize int
}

type StringMux

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

func New

func New(params Params) *StringMux

func (*StringMux) AcceptConn

func (m *StringMux) AcceptConn() (Conn, error)

AcceptConn reads from Conns channel. It returns io.ErrClosedPipe when the channel is closed. Users should use either AcceptConn or Conns, but never both.

func (*StringMux) Close

func (m *StringMux) Close() error

func (*StringMux) Conns

func (m *StringMux) Conns() <-chan Conn

Conns is the channel with incoming connections. Users should use either AcceptConn or Conns, but never both.

func (*StringMux) Done

func (m *StringMux) Done() <-chan struct{}

func (*StringMux) GetConn

func (m *StringMux) GetConn(streamID string) (Conn, error)

func (*StringMux) LocalAddr

func (m *StringMux) LocalAddr() net.Addr

func (*StringMux) RemoteAddr

func (m *StringMux) RemoteAddr() net.Addr

Jump to

Keyboard shortcuts

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