multiplex

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: AGPL-3.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewStreamTimeout is the default new stream timeout
	NewStreamTimeout = time.Minute
	// ResetStreamTimeout is the default stream reset timeout
	ResetStreamTimeout = 2 * time.Minute
	// WriteCoalesceDelay is the default coalesce delay
	WriteCoalesceDelay = 100 * time.Microsecond
)
View Source
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.

View Source
var ErrShutdown = errors.New("session shut down")

ErrShutdown is returned when operating on a shutdown session

View Source
var ErrTwoInitiators = errors.New("two initiators")

ErrTwoInitiators is returned when both sides think they're the initiator

View Source
var MaxMessageSize = 1 << 20

MaxMessageSize defines the maximum message size

View Source
var ReceiveTimeout = 5 * time.Second

ReceiveTimeout is 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.

Functions

This section is empty.

Types

type Multiplex

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

Multiplex is a mplex session.

func NewMultiplex

func NewMultiplex(con net.Conn, initiator bool) *Multiplex

NewMultiplex creates a new multiplexer session.

func (*Multiplex) Accept

func (mp *Multiplex) Accept() (*Stream, error)

Accept accepts the next stream from the connection.

func (*Multiplex) Close

func (mp *Multiplex) Close() error

Close closes the session.

func (*Multiplex) IsClosed

func (mp *Multiplex) IsClosed() bool

IsClosed returns true if the session is closed.

func (*Multiplex) NewNamedStream

func (mp *Multiplex) NewNamedStream(name string) (*Stream, error)

NewNamedStream creates a new named stream.

func (*Multiplex) NewStream

func (mp *Multiplex) NewStream() (*Stream, error)

NewStream creates a new stream.

type Stream

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

Stream is a stream !

func (*Stream) Close

func (s *Stream) Close() error

Close shuts down the stream

func (*Stream) Name

func (s *Stream) Name() string

Name returns the name of the stream

func (*Stream) Read

func (s *Stream) Read(b []byte) (int, error)

func (*Stream) Reset

func (s *Stream) Reset() error

Reset is used to reset the stream

func (*Stream) SetDeadline

func (s *Stream) SetDeadline(t time.Time) error

SetDeadline sets a general deadline timeout

func (*Stream) SetReadDeadline

func (s *Stream) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline timeout

func (*Stream) SetWriteDeadline

func (s *Stream) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline timeout

func (*Stream) Write

func (s *Stream) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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