graceful_shutdown

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ShutdownSignals receives shutdown signals to process
	ShutdownSignals = []os.Signal{
		os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
		syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP,
		syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM,
	}

	// DumpHeapShutdownSignals receives shutdown signals to process
	DumpHeapShutdownSignals = []os.Signal{
		syscall.SIGQUIT, syscall.SIGILL,
		syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS,
	}
)

Functions

func DefaultClosingAckStats added in v3.3.2

func DefaultClosingAckStats() map[string]ClosingAckStats

DefaultClosingAckStats returns the process-wide active-notice ack statistics.

func Done added in v3.3.2

func Done() <-chan struct{}

func Init

func Init(opts ...Option)

func IsDone added in v3.3.2

func IsDone() bool

func RegisterProtocol

func RegisterProtocol(name string)

RegisterProtocol registers protocol which would be destroyed before shutdown. Please make sure that the Init function has been invoked before, otherwise this function would not make any sense.

func Shutdown added in v3.3.2

func Shutdown(ctx context.Context) error

Types

type ClosingAckStats added in v3.3.2

type ClosingAckStats struct {
	Received uint64
	Removed  uint64
	Missed   uint64
}

ClosingAckStats is a lightweight, consumer-side statistic for active closing notices. Received means the consumer observed an active notice; Removed means directory removal succeeded; Missed means the notice was observed but did not match a local directory entry.

type ClosingDirectoryRegistry added in v3.3.2

type ClosingDirectoryRegistry interface {
	Register(serviceKey string, remover clusterdirectory.ClosingInstanceRemover)
	Unregister(serviceKey string, remover clusterdirectory.ClosingInstanceRemover)
	Find(serviceKey string) []clusterdirectory.ClosingInstanceRemover
}

ClosingDirectoryRegistry resolves directory-level removers by service key.

func DefaultClosingDirectoryRegistry added in v3.3.2

func DefaultClosingDirectoryRegistry() ClosingDirectoryRegistry

DefaultClosingDirectoryRegistry returns the process-wide closing directory registry.

type ClosingEvent added in v3.3.2

type ClosingEvent struct {
	Source      string
	InstanceKey string
	ServiceKey  string
	Address     string
}

ClosingEvent represents a single closing signal on the consumer side.

type ClosingEventHandler added in v3.3.2

type ClosingEventHandler interface {
	HandleClosingEvent(event ClosingEvent) bool
}

ClosingEventHandler handles closing signals from active and passive notification paths.

func DefaultClosingEventHandler added in v3.3.2

func DefaultClosingEventHandler() ClosingEventHandler

DefaultClosingEventHandler returns the default closing event handler.

type Option

type Option func(*Options)

func SetShutdownConfig added in v3.3.1

func SetShutdownConfig(cfg *global.ShutdownConfig) Option

func WithConsumerUpdateWaitTime

func WithConsumerUpdateWaitTime(duration time.Duration) Option

func WithNotifyTimeout added in v3.3.2

func WithNotifyTimeout(timeout time.Duration) Option

func WithOfflineRequestWindowTimeout

func WithOfflineRequestWindowTimeout(timeout time.Duration) Option

func WithRejectRequest

func WithRejectRequest() Option

func WithStepTimeout

func WithStepTimeout(timeout time.Duration) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithoutInternalSignal

func WithoutInternalSignal() Option

type Options

type Options struct {
	Shutdown *global.ShutdownConfig
}

func NewOptions

func NewOptions(opts ...Option) *Options

Jump to

Keyboard shortcuts

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