lifex

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Init 按注册顺序执行全部已注册的初始化函数并清空注册表, 任一失败立即停止后续执行并返回该错误,不自动执行已注册的解构函数。

func OnDeinit

func OnDeinit[F lifecycleFunc](fn F)

OnDeinit 注册解构函数,由 Wait 按注册逆序执行;带 context.Context 参数时传入 context.Background()。

func OnInit

func OnInit[F lifecycleFunc](fn F)

OnInit 注册初始化函数,由 Init 按注册顺序执行;带 context.Context 参数时传入 context.Background()。

func Shutdown

func Shutdown(r error)

Shutdown 主动触发退出,reason 作为 Wait 的返回值;重复调用无效。

func Wait

func Wait() error

Wait 阻塞等待 SIGINT/SIGTERM 信号或 Shutdown 触发退出, 然后按注册逆序执行全部解构函数;解构函数自身的错误经默认 slog 记录,不影响其余解构执行。 信号触发视为正常退出返回 nil,主动退出返回 Shutdown 携带的原因; 解构期间再次收到退出信号时跳过剩余解构强制退出,避免解构卡死导致进程无法终止。

Types

This section is empty.

Jump to

Keyboard shortcuts

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