mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-11 06:46:59 +08:00
fix(bootstrap module): add bootstrap module to meet future function (#674)
* fix(bootstrap module): add bootstrap module to meet future function * Fix readme * Fix panic because log.logger is nil * fix import --------- Co-authored-by: zbhan <zbhan@freewheel.tv>
This commit is contained in:
22
bootstrap/init_hook.go
Normal file
22
bootstrap/init_hook.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package bootstrap
|
||||
|
||||
import "nofx/config"
|
||||
|
||||
type InitHook func(config *config.Config) error
|
||||
|
||||
var InitHooks []InitHook
|
||||
|
||||
// RegisterInitHook 注册初始化钩子
|
||||
func RegisterInitHook(hook InitHook) {
|
||||
InitHooks = append(InitHooks, hook)
|
||||
}
|
||||
|
||||
// RunInitHooks 运行所有注册的初始化钩子
|
||||
func RunInitHooks(c *config.Config) error {
|
||||
for _, hookF := range InitHooks {
|
||||
if err := hookF(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user