hooks

package
v1.22.11 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyExit = "signal"
)

Variables

This section is empty.

Functions

func Done

func Done()

Done 主动结束进程

func Register

func Register(fn HookFunc, opts ...Option)

Register 注册hook

func WaitForShutdown

func WaitForShutdown()

WaitForShutdown 等待进程结束信号

Types

type HookFunc

type HookFunc func(ctx context.Context) error

HookFunc Hook 函数类型

type HookManager

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

func NewHookManager

func NewHookManager() *HookManager

func (*HookManager) Done

func (hm *HookManager) Done()

func (*HookManager) Listen

func (hm *HookManager) Listen()

Listen 启动信号监听

func (*HookManager) Register

func (hm *HookManager) Register(fn HookFunc, opts ...Option)

Register 注册 Hook

func (*HookManager) SendExitSignal

func (hm *HookManager) SendExitSignal()

func (*HookManager) Trigger

func (hm *HookManager) Trigger(s os.Signal)

Trigger 触发关闭流程

func (*HookManager) Wait

func (hm *HookManager) Wait()

Wait 等待退出信号

type HookPriority

type HookPriority int

HookPriority Hook 优先级排序

const (
	HighPriority HookPriority = iota
	DefaultPriority
	LowPriority
)

type Option

type Option func(*hook)

Option 配置选项

func WithPriority

func WithPriority(p HookPriority) Option

func WithTimeout

func WithTimeout(d time.Duration) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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