event_manager

package module
v0.0.0-...-a86be45 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrorsFuncEventAlreadyExists = "注册函数类事件失败,键名已经被注册"
	ErrorsFuncEventNotRegister   = "没有找到键名对应的函数"
	ShutdownHookerPrefix         = "graceful_shutdown_hooker_"
)

Variables

This section is empty.

Functions

func CreateEventManage

func CreateEventManage(prefix string) *eventManage

CreateEventManage 创建一个事件管理工厂

func GracefullyShutdown

func GracefullyShutdown()

GracefullyShutdown 执行优雅停机钩子事件

func RegisterShutdownHooker

func RegisterShutdownHooker(key string, hookers ...Event) bool

RegisterShutdownHooker 注册优雅停机钩子事件

func RegisterShutdownHookerAddChan

func RegisterShutdownHookerAddChan(key string, events ...Event) <-chan bool

RegisterShutdownHookerAddChan 注册优雅停机钩子事件,并额外返回一个取消信号 当执行优雅停机时,events 会先被执行,然后发送信号给通道

Types

type Event

type Event = func(args ...any)

Event 事件为无返回值的任意函数

Jump to

Keyboard shortcuts

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