add health module with component probing and controller implementation
This commit is contained in:
commit
7dc291e222
6 files changed
+289
No files matched your search
@@ -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
|
||||
})
|
||||
)
|
||||
Reference in new issue
Block a user