writerset

package
v0.0.0-...-86bd030 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package writerset implements a mechanism to add and remove writers from a construct similar to io.MultiWriter. Manually vendored from http://github.com/stephens2424/writerset

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrPartialWrite

type ErrPartialWrite struct {
	Writer          io.Writer
	Err             error
	Expected, Wrote int
}

ErrPartialWrite encapsulates an error from a WriterSet.

func (ErrPartialWrite) Error

func (e ErrPartialWrite) Error() string

Error returns the error string from the underlying error.

type WriterSet

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

WriterSet wraps multiple writers like io.MultiWriter, but such that individual writers are easy to add or remove as necessary.

func New

func New() *WriterSet

New initializes a new empty writer set.

func (*WriterSet) Add

func (ws *WriterSet) Add(w io.Writer) <-chan error

Add ensures w is in the set.

func (*WriterSet) Contains

func (ws *WriterSet) Contains(w io.Writer) bool

Contains determines if w is in the set.

func (*WriterSet) Flush

func (ws *WriterSet) Flush()

Flush implements http.Flusher by calling flush on all the underlying writers if they are also http.Flushers.

func (*WriterSet) Remove

func (ws *WriterSet) Remove(w io.Writer)

Remove ensures w is not in the set.

func (*WriterSet) Write

func (ws *WriterSet) Write(b []byte) (int, error)

Write writes data to each underlying writer. If an error occurs on an underlying writer, that writer is removed from the set. The error will be wrapped as an ErrPartialWrite and sent on the channel created when the writer was added.

Jump to

Keyboard shortcuts

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