This function wraps module service, and adds waiting for dependencies to start before starting, and dependant modules to stop before stopping this module service.
(serviceMap map[string]services.Service, mod string, logger log.Logger, modServ services.Service, startDeps []string, stopDeps []string)
| 9 | // This function wraps module service, and adds waiting for dependencies to start before starting, |
| 10 | // and dependant modules to stop before stopping this module service. |
| 11 | func newModuleServiceWrapper(serviceMap map[string]services.Service, mod string, logger log.Logger, modServ services.Service, startDeps []string, stopDeps []string) services.Service { |
| 12 | getDeps := func(deps []string) map[string]services.Service { |
| 13 | r := map[string]services.Service{} |
| 14 | for _, m := range deps { |
| 15 | s := serviceMap[m] |
| 16 | if s != nil { |
| 17 | r[m] = s |
| 18 | } |
| 19 | } |
| 20 | return r |
| 21 | } |
| 22 | |
| 23 | return NewModuleService(mod, logger, modServ, |
| 24 | func(_ string) map[string]services.Service { |
| 25 | return getDeps(startDeps) |
| 26 | }, |
| 27 | func(_ string) map[string]services.Service { |
| 28 | return getDeps(stopDeps) |
| 29 | }, |
| 30 | ) |
| 31 | } |
no test coverage detected