lifex

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 6 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(fn func() error)

OnDeinit 注册解构函数,由 Wait 在退出时按注册逆序执行。

func OnInit

func OnInit(fn func() error)

OnInit 注册初始化函数,由 Init 按注册顺序执行。

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