MCPcopy
hub / github.com/mailvelope/mailvelope / createController

Function createController

src/controller/main.controller.js:142–160  ·  view source on GitHub ↗
(type, port, eventCache)

Source from the content-addressed store, hash-verified

140}
141
142export 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
162async function allPortsConnected(id) {
163 const addPortAction = addPortQueue.queue.findLast(element => element.args[0].name.includes(id));

Callers

nothing calls this directly

Calls 4

getAllControllerByTypeFunction · 0.85
flushMethod · 0.80
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected