Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler guarantees execution of notifications after a critical section (the function passed to a Run method), even in the presence of process termination. It guarantees exactly once invocation of the provided notify functions.
func Chain ¶
Chain creates a new handler that invokes all notify functions when the critical section exits and then invokes the optional handler's notifications. This allows critical sections to be nested without losing exactly once invocations. Notify functions can invoke any cleanup needed but should not exit (which is the responsibility of the parent handler).
func New ¶
New creates a new handler that guarantees all notify functions are run after the critical section exits (or is interrupted by the OS), then invokes the final handler. If no final handler is specified, the default final is `os.Exit(1)`. A handler can only be used for one critical section.
func (*Handler) Close ¶
func (h *Handler) Close()
Close executes all the notification handlers if they have not yet been executed.