closepool

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: GPL-3.0 Imports: 4 Imported by: 8

Documentation

Overview

Package closepool allows pooling io.Closer instances and closing them in a single operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloserFunc added in v0.17.0

type CloserFunc func() error

CloserFunc allows to turn a suitable function into an io.Closer.

func (CloserFunc) Close added in v0.17.0

func (fx CloserFunc) Close() error

Close implements io.Closer.

type Pool

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

Pool allows pooling a set of io.Closer.

The zero value is ready to use.

func (*Pool) Add

func (p *Pool) Add(conn io.Closer)

Add adds a given io.Closer to the pool.

func (*Pool) Close

func (p *Pool) Close() error

Close closes all the io.Closer inside the pool iterating in backward order. Therefore, if one registers a TCP connection and then the corresponding TLS connection, the TLS connection is closed first. The returned error is the join of all the errors that occurred when closing connections.

Jump to

Keyboard shortcuts

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