multee

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 5 Imported by: 0

README

Multee, an io.Reader multiplexer

Go Reference Keep a Changelog v1.1.0 badge

Purpose

This package implements a multiplexer for io.Reader, making it possible to read from a single io.Reader several times concurrently, without needing to Seek back to the beginning.

Usage

Create a multee-reader from a single io.Reader, and create as many readers as you need:

	inputReader := strings.NewReader("Foo")
	mr := multee.NewMulteeReader(inputReader)
	r1 := mr.NewReader()
	r2 := mr.NewReader()
	r3 := mr.NewReader()

Now, you can use r1, r2 and r3 as a regular io.ReadCloser.

Each reader must be read in its own go-routine, and they must either be read until EOF or Close() must be called, or the MulteeReader will block.

The returned readers themselves are not concurrency-safe.

See also the code examples.

Testing

Just run poor man's CI, make test.

Contribute

Feel free to contribute, even if it's just to complain! Issues and pull requests are welcome.

See the contributing instructions for help to get started.

Documentation

Overview

Implements a multiplexer for io.Readers, making it possible to read from a single io.Reader several times, without needing to Seek back to the beginning.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed = errors.New("multeeReader already closed")
)

Functions

func NewMulteeReader

func NewMulteeReader(inputReader io.Reader) *multeeReader

Types

This section is empty.

Directories

Path Synopsis
alt
byteslice
Alternative implementation of the multee package, using a synchronized byte slice as a buffer.
Alternative implementation of the multee package, using a synchronized byte slice as a buffer.
byteslicechan
Alternative implementation of the multee package, using channels.
Alternative implementation of the multee package, using channels.
examples
alt-byteslicechan
Example code for how to use an alternative implementation of the multee package.
Example code for how to use an alternative implementation of the multee package.
huge
Example code for how to use the multee package on huge input streams (ie.
Example code for how to use the multee package on huge input streams (ie.
simple
Example code for how to use the multee package.
Example code for how to use the multee package.

Jump to

Keyboard shortcuts

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