Add a Stop() function

main v0.0.5
René Jochum 2 years ago
parent a4fb5811e8
commit 11ee36bb14
Signed by: jochum
GPG Key ID: F7D906F5E51E8E5E

@ -153,6 +153,34 @@ func (c *Components) Init(context *cli.Context) error {
return nil
}
func (c *Components) Stop() error {
// Sort Components by Priority DESC
components := make([]Component, len(c.components))
for _, com := range c.components {
components = append(components, com)
}
sort.SliceStable(components, func(i, j int) bool {
if components[i] == nil || components[j] == nil {
return false
}
return components[i].Priority() > components[j].Priority()
})
// Init them sorted now
for _, component := range components {
if c == nil {
continue
}
if err := component.Stop(); err != nil {
return err
}
}
return nil
}
func (c *Components) Health(context context.Context) HealthInfoMap {
result := make(HealthInfoMap, len(c.components))

Loading…
Cancel
Save