livelog

package
v0.0.0-...-8927fdd Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package livelog provides a buffer that can be simultaneously written to by one writer and read from by many readers.

Index

Constants

View Source
const MaxBufferSize = 2 << 20 // 2MB of output is way more than we expect.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is a WriteCloser that provides multiple Readers that each yield the same data. It is safe to Write to a Buffer while Readers consume that data. Its zero value is a ready-to-use buffer.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns a copy of the underlying buffer.

func (*Buffer) Close

func (b *Buffer) Close() error

Close signals EOF to all Readers.

func (*Buffer) Reader

func (b *Buffer) Reader() io.ReadCloser

Reader initializes and returns a ReadCloser that will emit the entire buffer. It is safe to call Read and Close concurrently.

func (*Buffer) String

func (b *Buffer) String() string

String returns a copy of the underlying buffer as a string.

func (*Buffer) Write

func (b *Buffer) Write(b2 []byte) (int, error)

Write appends data to the Buffer. It will wake any blocked Readers.

Jump to

Keyboard shortcuts

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