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

Function getStartupMessage

test/unit/insights-client-tests.js:490–530  ·  view source on GitHub ↗

* @param {{hostVersions, clientOptions}} [options] * @returns {Promise}

(options)

Source from the content-addressed store, hash-verified

488 * @returns {Promise}
489 */
490function getStartupMessage(options) {
491 let messageString;
492 let error;
493 options = options || {};
494
495 const client = getClient({
496 rpcCallback: m => messageString = m,
497 hostVersions: options.hostVersions,
498 clientOptions: options.clientOptions
499 });
500
501 const insights = new InsightsClient(client, {
502 errorCallback: err => error = err
503 });
504
505 insights.init();
506
507 return new Promise((resolve, reject) => {
508 setImmediate(() => {
509 insights.shutdown();
510
511 if (error) {
512 return reject(error);
513 }
514
515 // Wait for activity in the background
516 helper.setIntervalUntil(
517 () => !!messageString,
518 20,
519 500,
520 err => {
521 if (err) {
522 return reject('No RPC was invoked');
523 }
524
525 resolve({ message: JSON.parse(messageString), client });
526 }
527 );
528 });
529 });
530}

Callers 1

Calls 4

initMethod · 0.95
shutdownMethod · 0.95
getClientFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected