Documentation ¶
Overview ¶
Package batchcloser provides an object "BatchCloser" that collects multiple io.Closers and closes them all when Closers.Close is called.
It also provides helper methods for wrapping close/cancel functions in io.Closer objects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapCancel ¶
func WrapCancel(cancel context.CancelFunc) io.Closer
WrapCancel can be used to wrap a context.CancelFunc into an io.Closer.
Types ¶
type BatchCloser ¶
type BatchCloser struct {
// contains filtered or unexported fields
}
BatchCloser is a collection of io.Closer objects that are all closed when BatchCloser.Close is called.
func New ¶
func New(closers ...io.Closer) *BatchCloser
New returns a pointer to a new BatchCloser initialized with the given closers.
func (*BatchCloser) Add ¶
func (bc *BatchCloser) Add(closers ...io.Closer)
Add adds the given io.Closer objects to the BatchCloser.
This is not safe to be called concurrently.
func (*BatchCloser) Close ¶
func (bc *BatchCloser) Close() error
Close implements io.Closer and closes all of it's internal io.Closer objects, batching any errors into an errorsbp.Batch.