broadcaster

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2015 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffered

type Buffered struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Buffered keeps track of one or more observers watching the progress of an operation. For example, if multiple clients are trying to pull an image, they share a Buffered struct for the download operation.

func NewBuffered

func NewBuffered() *Buffered

NewBuffered returns an initialized Buffered structure.

func (*Buffered) Add

func (broadcaster *Buffered) Add(w io.Writer) error

Add adds an observer to the broadcaster. The new observer receives the data from the history buffer, and also all subsequent data.

func (*Buffered) Close

func (broadcaster *Buffered) Close()

Close signals to all observers that the operation has finished. It causes all calls to Wait to return nil.

func (*Buffered) CloseWithError

func (broadcaster *Buffered) CloseWithError(result error)

CloseWithError signals to all observers that the operation has finished. Its argument is a result that should be returned to waiters blocking on Wait.

func (*Buffered) Wait

func (broadcaster *Buffered) Wait() error

Wait blocks until the operation is marked as completed by the Close method, and all writer goroutines have completed. It returns the argument that was passed to Close.

func (*Buffered) Write

func (broadcaster *Buffered) Write(p []byte) (n int, err error)

Write adds data to the history buffer, and also writes it to all current observers.

type Unbuffered

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

Unbuffered accumulates multiple io.WriteCloser by stream.

func (*Unbuffered) Add

func (w *Unbuffered) Add(writer io.WriteCloser)

Add adds new io.WriteCloser.

func (*Unbuffered) Clean

func (w *Unbuffered) Clean() error

Clean closes and removes all writers. Last non-eol-terminated part of data will be saved.

func (*Unbuffered) Write

func (w *Unbuffered) Write(p []byte) (n int, err error)

Write writes bytes to all writers. Failed writers will be evicted during this call.

Jump to

Keyboard shortcuts

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