fanoutwriter

package module
v0.0.0-...-bc6abbd Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: MIT Imports: 3 Imported by: 0

README

FanoutWriter

FanoutWriter is a Golang package that implements io.WriteCloser and allows for multiple io.ReadClosers to be created which may read the data which is written to the FanoutWriter at a speed independent of other io.ReadClosers. This is ideal for a single data source which must broadcast data to multiple readers who, for example, may be sitting over a variable speed network connection.

Documentation

Documentation for the FanoutWriter may be found on godoc.org

License

This code is licensed using the MIT License, which may be found here: LICENSE.

Documentation

Overview

Package fanoutwriter provides the FanoutWriter structure, which is a buffer which may be written to and subsequently read from multiple variable speed readers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFellBehind                = errors.New("reader fell behind the writers buffer limit")
	ErrWriteWouldCauseFallBehind = errors.New("writing larger than the fanout limit will result in all readers falling behind")
)

Functions

This section is empty.

Types

type FanoutWriter

type FanoutWriter interface {
	io.WriteCloser
	NewReader() io.ReadCloser // Returns a new reader which begins reading depending on the configuration
}

FanoutWriter is a io.WriteCloser which can spawn multiple io.ReadClosers that read at different speeds.

func NewDefaultFanoutWriter

func NewDefaultFanoutWriter() FanoutWriter

NewDefaultFanoutWriter creates a new FanoutWriter with no initial data and with no buffer limit.

func NewFanoutWriter

func NewFanoutWriter(c *FanoutWriterConfig) FanoutWriter

NewFanoutWriter creates a new FanoutWriter with the configuration passed.

type FanoutWriterConfig

type FanoutWriterConfig struct {
	Buf           []byte // Initial buffer of the writer.
	Limit         int    // Limit for the size of which buffer may grow
	ReadFromStart bool   // Whether or not to start a reader from the end or beginning of the buffer.
}

Jump to

Keyboard shortcuts

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