41 lines
686 B
Go
41 lines
686 B
Go
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
|
|
})
|
|
)
|