MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / _getStatusEvent

Method _getStatusEvent

lib/insights-client.js:357–387  ·  view source on GitHub ↗

* @returns {String} Returns a json string with the startup message. * @private

()

Source from the content-addressed store, hash-verified

355 * @private
356 */
357 _getStatusEvent() {
358 const cc = this._client.controlConnection;
359 const options = this._client.options;
360 const state = this._client.getState();
361 const connectedNodes = {};
362
363 state.getConnectedHosts().forEach(h => {
364 connectedNodes[h.address] = {
365 connections: state.getOpenConnections(h),
366 inFlightQueries: state.getInFlightQueries(h)
367 };
368 });
369
370 const message = {
371 metadata: {
372 name: 'driver.status',
373 insightMappingId: 'v1',
374 insightType: 'EVENT',
375 timestamp: Date.now(),
376 tags: { language: 'nodejs' }
377 },
378 data: {
379 clientId: options.id,
380 sessionId: this._sessionId,
381 controlConnection: cc.host ? cc.host.address : undefined,
382 connectedNodes
383 }
384 };
385
386 return JSON.stringify(message);
387 }
388
389 /**
390 * Cleans any timer used internally and sets the client as closed.

Callers 1

_sendStatusEventMethod · 0.95

Calls 5

forEachMethod · 0.65
getConnectedHostsMethod · 0.65
getOpenConnectionsMethod · 0.65
getInFlightQueriesMethod · 0.65
stringifyMethod · 0.45

Tested by

no test coverage detected