Documentation ¶
Overview ¶
Package writerset implements a mechanism to add and remove writers from a construct similar to io.MultiWriter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrPartialWrite ¶
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. This function is here for ease of use and backward compatibility, but a zero-value WriterSet is valid and ready for use.
func (*WriterSet) Add ¶
Add ensures w is in the set. w must be a valid map key or Add will panic. The returned channel is written to if an error occurs writing to this writer, and in that case, the writer is removed from the set. The error will be of type ErrorPartialWrite. The channel is closed when the writer is removed from the set, with or without an error.
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 ¶
Remove ensures w is not in the set. If it is in the set, the error channel associated with it will be closed.