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:
Shui
2025-11-06 21:53:10 -05:00
committed by GitHub
parent a8a2b6b849
commit 179e5c69bf
7 changed files with 769 additions and 189 deletions

22
bootstrap/init_hook.go Normal file
View 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
}