kubernetes: k8s.io/kubernetes/pkg/util/interrupt Index | Files

package interrupt

import "k8s.io/kubernetes/pkg/util/interrupt"

Index

Package Files

interrupt.go

type Handler Uses

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 Uses

func Chain(handler *Handler, notify ...func()) *Handler

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 Uses

func New(final func(os.Signal), notify ...func()) *Handler

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 Uses

func (h *Handler) Close()

Close executes all the notification handlers if they have not yet been executed.

func (*Handler) Run Uses

func (h *Handler) Run(fn func() error) error

Run ensures that any notifications are invoked after the provided fn exits (even if the process is interrupted by an OS termination signal). Notifications are only invoked once per Handler instance, so calling Run more than once will not behave as the user expects.

func (*Handler) Signal Uses

func (h *Handler) Signal(s os.Signal)

Signal is called when an os.Signal is received, and guarantees that all notifications are executed, then the final handler is executed. This function should only be called once per Handler instance.

Package interrupt imports 4 packages (graph) and is imported by 164 packages. Updated 2017-12-14. Refresh now. Tools for package owners.