function silentRpcErrors(error) { if (!process.connected && error.code === 'ERR_IPC_CHANNEL_CLOSED') return; throw error; }
/** * @api {get} /api/v1/service/zwave/status Get Zwave Status * @apiName getStatus * @apiGroup Zwave */ async function getStatus(req, res) { res.json({ connected: zwaveManager.connected, scanInProgress: zwaveManager.scanInProgress, ready: zwaveManager.ready, }); }
it('handleShutdown, close connection', async () => { const cache = new RedisCacheAdapter(null, 5); await cache.handleShutdown(); setTimeout(() => { expect(cache.client.connected).toBe(false); }, 0); });
db.task(t => { const d: Date = t.ctx.start; const duration: number = t.ctx.duration; const parentTag = t.ctx.parent.tag; const connected: boolean = t.ctx.connected; return t.batch([]); });
it("check onConnected", () => { let transporter = new BaseTransporter(); let afterConnect = jest.fn(); expect(transporter.connected).toBe(false); transporter.init(null, null, afterConnect); transporter.onConnected(); expect(transporter.connected).toBe(true); expect(afterConnect).toHaveBeenCalledTimes(1); afterConnect.mockClear(); transporter.onConnected(true); expect(afterConnect).toHaveBeenCalledTimes(1); expect(afterConnect).toHaveBeenCalledWith(true); });
/** * Local broker is ready (all services loaded). * Send INFO packet to all other nodes */ ready() { if (this.connected) { this.isReady = true; this.metrics.set(METRIC.MOLECULER_TRANSIT_READY, 1); return this.discoverer.localNodeReady(); } }
/** * @description Get MQTT status. * @returns {Object} Current MQTT network status. * @example * status(); */ function status() { const mqttStatus = { configured: this.configured, connected: this.connected, }; return mqttStatus; }
/** * @description Heal Zwave network * @example * zwave.healNetwork(); */ function healNetwork() { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Heal network.`); this.zwave.healNetwork(); }
/** * @private */ failIfNotConnected() { if (!this.connected) { throw new KafkaJSConnectionError('Not connected', { broker: `${this.host}:${this.port}`, }) } }
function prepareProcess(name, disposeCallback) { process.title = 'ndb/' + name; function silentRpcErrors(error) { if (!process.connected && error.code === 'ERR_IPC_CHANNEL_CLOSED') return; throw error; } process.on('uncaughtException', silentRpcErrors); process.on('unhandledRejection', silentRpcErrors); // dispose when child process is disconnected process.on('disconnect', () => disposeCallback()); }
/** * @description Request all params of a node. * @param {number} nodeId - The NodeId. * @example * zwave.refreshNodeParams(1); */ function refreshNodeParams(nodeId) { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Request all params of nodeId = ${nodeId}`); this.zwave.requestAllConfigParams(nodeId); }
/** * @api {get} /api/v1/service/zwave/status Get Zwave Status * @apiName getStatus * @apiGroup Zwave */ async function getStatus(req, res) { res.json({ connected: zwaveManager.connected, scanInProgress: zwaveManager.scanInProgress, ready: zwaveManager.ready, }); }
/** * @api {get} /api/v1/service/zwave/status Get Zwave Status * @apiName getStatus * @apiGroup Zwave */ async function getStatus(req, res) { res.json({ connected: zwaveManager.connected, scanInProgress: zwaveManager.scanInProgress, ready: zwaveManager.ready, }); }
/** * @description Heal Zwave network * @example * zwave.healNetwork(); */ function healNetwork() { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Heal network.`); this.zwave.healNetwork(); }
/** * @description Heal Zwave network * @example * zwave.healNetwork(); */ function healNetwork() { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Heal network.`); this.zwave.healNetwork(); }