add health module with component probing and controller implementation

This commit is contained in:
Artёm Mishin committed 2025-04-25 15:25:07 +03:00
commit 7dc291e222
6 files changed
+289

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
package health
import (
"go.uber.org/fx"
"universe.mrlokop.dev/core/app"
um "universe.mrlokop.dev/core/modules"
)
type moduleConfig struct {
Group string `mapstructure:"group"`
}
const (
kind = "universe:health:controller"
)
var (
Module = um.SimpleModule(kind, func(ctx um.ModuleFactoryContext) error {
cfg := &moduleConfig{}
err := ctx.ExtractConfig(cfg)
if err != nil {
return err
}
if cfg.Group == "" {
cfg.Group = DefaultComponentGroup
}
ctx.Provide(fx.Annotate(
func(components []ProbableComponent) Controller {
return &controllerImpl{
components: components,
}
},
fx.ParamTags(app.Group(cfg.Group)),
))
return nil
})
)