(name string, initMap map[string]bool, servicesMap map[string]services.Service)
| 114 | } |
| 115 | |
| 116 | func (m *Manager) initModule(name string, initMap map[string]bool, servicesMap map[string]services.Service) error { |
| 117 | if _, ok := m.modules[name]; !ok { |
| 118 | return fmt.Errorf("unrecognised module name: %s", name) |
| 119 | } |
| 120 | |
| 121 | // initialize all of our dependencies first |
| 122 | deps := m.orderedDeps(name) |
| 123 | deps = append(deps, name) // lastly, initialize the requested module |
| 124 | |
| 125 | for _, n := range deps { |
| 126 | // Skip already initialized modules |
| 127 | if initMap[n] { |
| 128 | continue |
| 129 | } |
| 130 | |
| 131 | mod := m.modules[n] |
| 132 | |
| 133 | var serv services.Service |
| 134 | |
| 135 | if mod.initFn != nil { |
| 136 | s, err := mod.initFn() |
| 137 | if err != nil { |
| 138 | return errors.Wrap(err, fmt.Sprintf("error initialising module: %s", n)) |
| 139 | } |
| 140 | |
| 141 | if s != nil { |
| 142 | // We pass servicesMap, which isn't yet complete. By the time service starts, |
| 143 | // it will be fully built, so there is no need for extra synchronization. |
| 144 | serv = newModuleServiceWrapper(servicesMap, n, m.logger, s, m.DependenciesForModule(n), m.inverseDependenciesForModule(n)) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if serv != nil { |
| 149 | servicesMap[n] = serv |
| 150 | } |
| 151 | |
| 152 | initMap[n] = true |
| 153 | } |
| 154 | |
| 155 | return nil |
| 156 | } |
| 157 | |
| 158 | // UserVisibleModuleNames gets list of module names that are |
| 159 | // user visible. Returned list is sorted in increasing order. |
no test coverage detected