Register adds not-initialized (configured) module into registry. lazyInit function will be called on first request to get the module from registry.
(mod module.Module, lazyInit func() error)
| 58 | // lazyInit function will be called on first request to get the module from |
| 59 | // registry. |
| 60 | func (r *Registry) Register(mod module.Module, lazyInit func() error) error { |
| 61 | instName := mod.InstanceName() |
| 62 | if instName == "" { |
| 63 | panic("module with empty instance name cannot be added to the registry") |
| 64 | } |
| 65 | |
| 66 | _, ok := r.instances[instName] |
| 67 | if ok { |
| 68 | return ErrInstanceNameDuplicate |
| 69 | } |
| 70 | |
| 71 | r.instances[instName] = registryEntry{ |
| 72 | Mod: mod, |
| 73 | LazyInit: lazyInit, |
| 74 | } |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | func (r *Registry) AddAlias(instanceName string, alias string) error { |
| 79 | if instanceName == "" { |
no test coverage detected