Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Closer ¶
type Closer interface {
// CloseWithContext calls the closer with the given context.
CloseWithContext(context.Context) error
}
Closer is the interface that wraps the CloseWithContext method.
type Closers ¶
type Closers []Closer
Closers is a collection of closers. It is used to store all the closers that need to be called when the server is terminated.
func (*Closers) AddCloser ¶
AddCloser adds a closer to the server. The closer will be called when the server is closed. The closer can be a function that takes no arguments, a function that returns an error, a function that takes a context, a function that takes a context and returns an error or, a value that implements the io.Closer or this package's Closer interface.
func (*Closers) CloseWithContext ¶
CloseWithContext calls the CloseWithContext method on all closers. Errors from individual closers are accumulated with errors.Join so callers can match each underlying error via errors.Is / errors.As.
func (*Closers) PrependCloser ¶
PrependCloser adds a closer to the server but at the beginning of the closers list.