Documentation ¶
Index ¶
- Constants
- Variables
- type MemoryManager
- type Multiplex
- func (m *Multiplex) Accept() (*Stream, error)
- func (mp *Multiplex) Close() error
- func (mp *Multiplex) CloseChan() <-chan struct{}
- func (mp *Multiplex) IsClosed() bool
- func (mp *Multiplex) NewNamedStream(ctx context.Context, name string) (*Stream, error)
- func (mp *Multiplex) NewStream(ctx context.Context) (*Stream, error)
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) CloseRead() error
- func (s *Stream) CloseWrite() error
- func (s *Stream) Name() string
- func (s *Stream) Read(b []byte) (int, error)
- func (s *Stream) Reset() error
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) SetReadDeadline(t time.Time) error
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) Write(b []byte) (int, error)
Constants ¶
const ( MaxMessageSize = 1 << 20 BufferSize = 4096 MaxBuffers = 4 MinMemoryReservation = 3 * BufferSize )
Variables ¶
var ( ErrStreamReset = errors.New("stream reset") ErrStreamClosed = errors.New("closed stream") )
var (
ChunkSize = BufferSize - 20
)
var ErrInvalidState = errors.New("received an unexpected message from the peer")
ErrInvalidState is returned when the other side does something it shouldn't. In this case, we close the connection to be safe.
var ErrShutdown = errors.New("session shut down")
ErrShutdown is returned when operating on a shutdown session
var ErrTwoInitiators = errors.New("two initiators")
ErrTwoInitiators is returned when both sides think they're the initiator
var ReceiveTimeout = 5 * time.Second
Max time to block waiting for a slow reader to read from a stream before resetting it. Preferably, we'd have some form of back-pressure mechanism but we don't have that in this protocol.
var ResetStreamTimeout = 2 * time.Minute
Functions ¶
This section is empty.
Types ¶
type MemoryManager ¶ added in v0.4.0
type MemoryManager interface { // ReserveMemory reserves memory / buffer. ReserveMemory(size int, prio uint8) error // ReleaseMemory explicitly releases memory previously reserved with ReserveMemory ReleaseMemory(size int) }
The MemoryManager allows management of memory allocations.
type Multiplex ¶
type Multiplex struct {
// contains filtered or unexported fields
}
Multiplex is a mplex session.
func NewMultiplex ¶
NewMultiplex creates a new multiplexer session.
func (*Multiplex) CloseChan ¶ added in v0.4.0
func (mp *Multiplex) CloseChan() <-chan struct{}
CloseChan returns a read-only channel which will be closed when the session is closed
func (*Multiplex) NewNamedStream ¶
NewNamedStream creates a new named stream.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}