mux

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadTimeout   = 5 * time.Second
	DefaultAcceptTimeout = 5 * time.Second
)

Variables

View Source
var (
	ErrConnectionClosed  = errors.New("network connection closed")
	ErrConnectionTimeout = errors.New("network connection timed out")
	ErrHandlerClosed     = errors.New("handler is already closed")
	ErrUnknownStream     = errors.New("unknown stream")
)
View Source
var ErrStreamByteWrite = errors.New("dial: stream byte not written")

Functions

func Dial

func Dial(network string, address string, stream byte) (net.Conn, error)

Dial connects to the stream of Mux listening on address on the named network.

func DialContext

func DialContext(ctx context.Context, network string, address string, stream byte) (net.Conn, error)

DialContext acts like Dial but takes a context.

func DialContextTLS

func DialContextTLS(
	ctx context.Context,
	network string,
	address string,
	stream byte,
	config *tls.Config,
) (net.Conn, error)

DialContextTLS acts like DialTLS but takes a context.

func DialTLS

func DialTLS(network string, address string, stream byte, config *tls.Config) (net.Conn, error)

DialTLS connects to the stream of Mux listening on address on the named network over TLS.

func NewGRPCConn

func NewGRPCConn(target string, stream byte, opts ...grpc.DialOption) (*grpc.ClientConn, error)

NewGRPCConn creates new grpc.ClientConn that uses Dial for initiating connections.

func NewGRPCConnTLS

func NewGRPCConnTLS(target string, stream byte, config *tls.Config, opts ...grpc.DialOption) (*grpc.ClientConn, error)

NewGRPCConnTLS creates new grpc.ClientConn that uses DialTLS for initiating connections.

func NewRaftTransport

func NewRaftTransport(
	mux *Mux,
	stream byte,
	maxPool int,
	timeout time.Duration,
	logger hclog.Logger,
) *raft.NetworkTransport

NewRaftTransport creates new raft.NetworkTransport that uses Mux`s stream.

func NewRaftTransportTLS

func NewRaftTransportTLS(
	mux *Mux,
	stream byte,
	maxPool int,
	timeout time.Duration,
	config *tls.Config,
	logger hclog.Logger,
) *raft.NetworkTransport

NewRaftTransportTLS creates new raft.NetworkTransport that uses Mux`s stream over TLS.

Types

type Mux

type Mux struct {
	ReadTimeout   time.Duration
	AcceptTimeout time.Duration
	// contains filtered or unexported fields
}

Mux is a multiplexer for a net.Listener.

func Listen

func Listen(network string, address string) (*Mux, error)

Listen creates Mux using net.Listen.

func ListenTLS

func ListenTLS(network string, address string, config *tls.Config) (*Mux, error)

ListenTLS creates Mux using tls.Listen.

func (*Mux) Addr

func (mux *Mux) Addr() net.Addr

Addr returns the multiplexer's network address.

func (*Mux) Close

func (mux *Mux) Close() (err error)

Close closes the multiplexer and waits for open connections to close.

func (*Mux) Listen

func (mux *Mux) Listen(stream byte) net.Listener

Listen returns a listener that receives connections for specified stream.

func (*Mux) Serve

func (mux *Mux) Serve() error

Serve handles connections from ln and multiplexes then across registered listeners.

Jump to

Keyboard shortcuts

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