mux

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInstance = errors.New("invalid de-multiplexer")
	ErrInvalidChannel  = errors.New("invalid channel key")
)

Functions

This section is empty.

Types

type DeMultiplexer

type DeMultiplexer interface {
	io.Reader

	// Copy launch a continuously reading from the main io.Reader and writing to the correct channel io.Writer
	// A good use case is to use it in a goroutine.
	//
	// returns any error.
	Copy() error

	// NewChannel registers a new channel to the given io.Writer for the given key as discriminant
	//
	// Parameters:
	//   key is a rune/byte parameter to identify the channel.
	//   w io.Writer the io.writer to write to.
	NewChannel(key rune, w io.Writer)
}

func NewDeMultiplexer

func NewDeMultiplexer(r io.Reader, delim byte, size int) DeMultiplexer

NewDeMultiplexer creates a new DeMultiplexer using the given io.Reader, delimiter byte, and optional buffer size. If the buffer size is 0, a default buffer size of 4096 will be used.

Parameters:

r io.Reader - the input reader
delim byte - the delimiter byte used to identify each block of data
size int - the buffer size

Return type: DeMultiplexer

type Multiplexer

type Multiplexer interface {
	// NewChannel returns an io.Writer that can be used to mux the given byte slice with other channel into the main writer
	//
	// key is a rune/byte parameter to identify the channel.
	// io.Writer is the return type.
	NewChannel(key rune) io.Writer
}

func NewMultiplexer

func NewMultiplexer(w io.Writer, delim byte) Multiplexer

NewMultiplexer creates a new Multiplexer with the given io.Writer and delimiter.

w: io.Writer to write to. delim: byte delimiter to use. Returns a Multiplexer.

Jump to

Keyboard shortcuts

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