(type, port, eventCache)
| 140 | } |
| 141 | |
| 142 | export async function createController(type, port, eventCache) { |
| 143 | const existingController = (await getAllControllerByType(type))[0]; |
| 144 | if (existingController && existingController.persistent) { |
| 145 | return existingController; |
| 146 | } |
| 147 | const subContr = createControllerInstance(type, port); |
| 148 | if (!port && !subContr.id) { |
| 149 | throw new Error('Subcontroller instantiated without port requires id.'); |
| 150 | } |
| 151 | eventCache?.flush(subContr); |
| 152 | if (subContr.singleton) { |
| 153 | // there should be only one instance for this type, new instance overwrites old |
| 154 | if (existingController) { |
| 155 | await controllerPool.delete(existingController.id); |
| 156 | } |
| 157 | } |
| 158 | await controllerPool.set(subContr.id, subContr); |
| 159 | return subContr; |
| 160 | } |
| 161 | |
| 162 | async function allPortsConnected(id) { |
| 163 | const addPortAction = addPortQueue.queue.findLast(element => element.args[0].name.includes(id)); |
nothing calls this directly
no test coverage detected