mux

package
v1.0.22 Latest Latest
Warning

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

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

Documentation

Overview

Package mux multiplexes a connection using gRPC (http2) streams. The gRPC server is started on a connection that can't be shared. When the client connects to the server the connection is meant to be persistent. Once the connection is establised the client can call NewStream and get multiple streams on a single connection allowing to multiplex the base channel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConn

func NewConn(rwc io.ReadWriteCloser) net.Conn

NewConn returns a new Conn wrapping the ReadWriteCloser.

Types

type Conn

type Conn struct {
	io.ReadWriteCloser
}

Conn implements net.Conn interface on a ReadWriteCloser.

func (*Conn) Close

func (mc *Conn) Close() error

Close closes the underlying closer.

func (*Conn) CloseRead

func (mc *Conn) CloseRead() error

CloseRead closes the read side of the ReadWriteCloser if it implements CloseRead, otherwise it closes the closer.

func (*Conn) CloseWrite

func (mc *Conn) CloseWrite() error

CloseWrite closes the write side of the ReadWriteCloser if it implements CloseWrite, otherwise it closes the closer.

func (*Conn) LocalAddr

func (mc *Conn) LocalAddr() net.Addr

LocalAddr returns the conn addr.

func (*Conn) Read

func (mc *Conn) Read(b []byte) (int, error)

Read reads from the underlying reader.

func (*Conn) RemoteAddr

func (mc *Conn) RemoteAddr() net.Addr

RemoteAddr returns the conn add.

func (*Conn) SetDeadline

func (mc *Conn) SetDeadline(t time.Time) error

SetDeadline -> unimplemented, calling it returns an error.

func (*Conn) SetReadDeadline

func (mc *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline -> unimplemented, calling it returns an error.

func (*Conn) SetWriteDeadline

func (mc *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline -> unimplemented, calling it returns an error.

func (*Conn) Write

func (mc *Conn) Write(b []byte) (int, error)

Write writes to the underlying writer.

type ConnBuilder

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

ConnBuilder create new connections multiplexed throug gRPC.

func NewConnBuilder

func NewConnBuilder(ctx context.Context, rwc io.ReadWriteCloser) (*ConnBuilder, error)

NewConnBuilder creates a ConnBuilder using a base ReadWriteCloser.

func (*ConnBuilder) Accept

func (sb *ConnBuilder) Accept() (net.Conn, error)

Accept returns a new Conn.

func (*ConnBuilder) Close

func (sb *ConnBuilder) Close() error

Close closes ConnBuilder.

type Listener

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

Listener implements net.Listener multiplexed over a gRPC connection

func NewListener

func NewListener(f io.ReadWriteCloser) *Listener

NewListener returns a Listener backed by gRPC service.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept returns the next available gRPC stream.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener address.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the Listener and stops the underlying gRPC server.

type Message

type Message struct{}

Message implements stream.MessageReadWriteCloser interface

func (Message) BuildMsg

func (sm Message) BuildMsg() interface{}

BuildMsg returns a new message that can be sent through a forwarding stream.

func (Message) CloseMsg

func (sm Message) CloseMsg() interface{}

CloseMsg returns a new message to notify the other side that the stream is closed.

func (Message) GetBytes

func (sm Message) GetBytes(m interface{}) ([]byte, error)

GetBytes reads the bytes from the message.

func (Message) SetBytes

func (sm Message) SetBytes(m interface{}, b []byte)

SetBytes sets the meessage bytes.

Jump to

Keyboard shortcuts

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