graceful

package
v0.0.0-...-adf7d95 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminating

func IsTerminating(ctx context.Context) bool

IsTerminating returns true if termination is in progress. ctx must be the context created WithTermination(). It is safe for concurrent usage.

func IsTerminationContext

func IsTerminationContext(ctx context.Context) bool

IsTerminationContext returns "true" if ctx is termination one. It is safe for concurrent usage.

func Shutdown

func Shutdown(ctx context.Context, callback ShutdownCallback)

Shutdown handles termination using terminationCtx. ctx must be the context created WithTermination(). Callback is always called.

func Terminate

func Terminate(ctx context.Context, err error, exitCode int)

Terminate starts termination if not yet. ctx must be the context created WithTermination(). It is safe for concurrent usage.

func WithTermination

func WithTermination(ctx context.Context) context.Context

WithTermination returns a termination context that is marked done when SIGINT or SIGTERM received or Terminate() called.

Types

type ShutdownCallback

type ShutdownCallback func(ctx context.Context, desc TerminationDescriptor)

type TerminationDescriptor

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

func (TerminationDescriptor) Err

func (t TerminationDescriptor) Err() error

func (TerminationDescriptor) ExitCode

func (t TerminationDescriptor) ExitCode() int

func (TerminationDescriptor) Signal

func (t TerminationDescriptor) Signal() os.Signal

Jump to

Keyboard shortcuts

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