core

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJob

func AddJob(spec string, cmd func()) error

func CancelContext added in v0.2.0

func CancelContext()

CancelContext 取消全局context,通知所有协程退出

func Context

func Context() context.Context

Context 获取全局顶层context

func GetContextWithCancel

func GetContextWithCancel() (context.Context, context.CancelFunc)

func GracefulShutdown added in v0.2.0

func GracefulShutdown()

GracefulShutdown 优雅关闭应用程序,等待所有hook完成并退出

func RegisterHook

func RegisterHook(name string, cb func()) context.Context

RegisterHook 注册系统退出的hook

func SetLogger added in v0.2.0

func SetLogger(logger_ Logger)

SetLogger 设置全局logger

func WaitForShutdown

func WaitForShutdown(d ...int)

WaitForShutdown 阻塞等待关闭信号

如果传入d, 视为等待d秒结束
如果没有传值, 则默认为等待信号

Types

type Logger added in v0.2.0

type Logger interface {
	Debug(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Warn(msg string, keysAndValues ...interface{})
	Error(msg string, keysAndValues ...interface{})
}

Logger 日志接口,避免循环引用

Jump to

Keyboard shortcuts

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