MCPcopy
hub / github.com/mongodb/node-mongodb-native / measureRoundTripTime

Method measureRoundTripTime

src/sdam/monitor.ts:534–565  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

532 }
533
534 private measureRoundTripTime() {
535 const start = processTimeMS();
536
537 if (this.closed) {
538 return;
539 }
540
541 const connection = this.connection;
542 if (connection == null) {
543 connect(this.monitor.connectOptions).then(
544 connection => {
545 this.measureAndReschedule(start, connection);
546 },
547 () => {
548 this.connection = undefined;
549 }
550 );
551 return;
552 }
553
554 const commandName =
555 connection.serverApi?.version || connection.helloOk ? 'hello' : LEGACY_HELLO_COMMAND;
556
557 connection.command(ns('admin.$cmd'), { [commandName]: 1 }, undefined).then(
558 () => this.measureAndReschedule(start),
559 () => {
560 this.connection?.destroy();
561 this.connection = undefined;
562 return;
563 }
564 );
565 }
566}
567
568/**

Callers 2

constructorMethod · 0.95
measureAndRescheduleMethod · 0.95

Calls 6

measureAndRescheduleMethod · 0.95
processTimeMSFunction · 0.90
connectFunction · 0.90
nsFunction · 0.90
commandMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected