closer

package
v14.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-3-Clause, BSD-3-Clause Imports: 6 Imported by: 0

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

func (cs *Closers) AddCloser(v any)

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

func (cs *Closers) CloseWithContext(ctx context.Context) (joinedErr error)

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

func (cs *Closers) PrependCloser(v any)

PrependCloser adds a closer to the server but at the beginning of the closers list.

Jump to

Keyboard shortcuts

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