WithModule allows API module selection. Connector implementation must provide list of modules that are currently supported. This defines a list of module a user could switch to. Any out of scope module will be ignored. If user supplied unsupported module, then it will use this fallback.
(moduleID common.ModuleID, supported common.Modules, fallbackID common.ModuleID)
| 32 | // This defines a list of module a user could switch to. Any out of scope module will be ignored. |
| 33 | // If user supplied unsupported module, then it will use this fallback. |
| 34 | func (p *Module) WithModule(moduleID common.ModuleID, supported common.Modules, fallbackID common.ModuleID) { |
| 35 | modules := datautils.NewDefaultMap(supported, |
| 36 | func(unknownID common.ModuleID) common.Module { |
| 37 | // Unknown module ids will receive a fallback module. |
| 38 | return supported[fallbackID] |
| 39 | }, |
| 40 | ) |
| 41 | |
| 42 | p.Selection = modules.Get(moduleID) |
| 43 | p.supported = supported |
| 44 | } |
no test coverage detected