graceful

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Graceful

背景

用于服务的优雅退出场景

How to use

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGracefulExitTimeout = fmt.Errorf("graceful exit timeout")

Functions

func WaitSysExitSignal

func WaitSysExitSignal(x IGraceful, timeout time.Duration) error

Types

type Graceful

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

func NewGraceful

func NewGraceful(opts ...Options) *Graceful

func (*Graceful) Add

func (x *Graceful) Add(_ context.Context, exitings ...IExiting) error

func (*Graceful) Wait

func (x *Graceful) Wait(ctx context.Context) error

type IExiting

type IExiting interface {
	Name() string
	Stop(ctx context.Context) error
}

type IGraceful

type IGraceful interface {
	Add(ctx context.Context, exitings ...IExiting) error
	// Wait 等待终止进程的终止信号,并监听所有的 IExiting 退出之后才推出
	Wait(ctx context.Context) error
}

type ILogger

type ILogger interface {
	Warn(ctx context.Context, message string)
}

type Options

type Options func(x *Graceful)

func WithLogger

func WithLogger(logger ILogger) Options

func WithRoutinepool

func WithRoutinepool(pool routinepool.Pool) Options

Jump to

Keyboard shortcuts

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