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

Method wake

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

Source from the content-addressed store, hash-verified

607 }
608
609 wake() {
610 const currentTime = processTimeMS();
611 const timeSinceLastCall = currentTime - this.lastExecutionEnded;
612
613 // TODO(NODE-4674): Add error handling and logging to the monitor
614 if (timeSinceLastCall < 0) {
615 return this._executeAndReschedule();
616 }
617
618 if (this.isExecutionInProgress) {
619 return;
620 }
621
622 // debounce multiple calls to wake within the `minInterval`
623 if (this.isExpeditedCallToFnScheduled) {
624 return;
625 }
626
627 // reschedule a call as soon as possible, ensuring the call never happens
628 // faster than the `minInterval`
629 if (timeSinceLastCall < this.minHeartbeatFrequencyMS) {
630 this.isExpeditedCallToFnScheduled = true;
631 this._reschedule(this.minHeartbeatFrequencyMS - timeSinceLastCall);
632 return;
633 }
634
635 this._executeAndReschedule();
636 }
637
638 stop() {
639 this.stopped = true;

Callers 3

monitor.test.tsFile · 0.80
requestCheckMethod · 0.80
monitorServerFunction · 0.80

Calls 2

_rescheduleMethod · 0.95
processTimeMSFunction · 0.90

Tested by

no test coverage detected