MCPcopy
hub / github.com/grafana/dskit / newModuleServiceWrapper

Function newModuleServiceWrapper

modules/module_service_wrapper.go:11–31  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
11func 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}

Callers 1

initModuleMethod · 0.85

Calls 1

NewModuleServiceFunction · 0.85

Tested by

no test coverage detected