MCPcopy
hub / github.com/redis/node-redis / monitor

Method monitor

packages/client/lib/client/commands-queue.ts:475–506  ·  view source on GitHub ↗
(callback: MonitorCallback, options?: CommandOptions)

Source from the content-addressed store, hash-verified

473 }
474
475 monitor(callback: MonitorCallback, options?: CommandOptions) {
476 return new Promise<void>((resolve, reject) => {
477 const typeMapping = options?.typeMapping ?? {};
478 this.#toWrite.add(
479 {
480 args: ["MONITOR"],
481 chainId: options?.chainId,
482 abort: undefined,
483 timeout: undefined,
484 // using `resolve` instead of using `.then`/`await` to make sure it'll be called before processing the next reply
485 resolve: () => {
486 // after running `MONITOR` only `MONITOR` and `RESET` replies are expected
487 // any other command should cause an error
488
489 // if `RESET` already overrides `onReply`, set monitor as it's fallback
490 if (this.#resetFallbackOnReply) {
491 this.#resetFallbackOnReply = callback;
492 } else {
493 this.decoder.onReply = callback;
494 }
495
496 this.decoder.getTypeMapping = () => typeMapping;
497 resolve();
498 },
499 reject,
500 channelsCounter: undefined,
501 typeMapping,
502 },
503 options?.asap,
504 );
505 });
506 }
507
508 resetDecoder() {
509 this.#resetDecoderCallbacks();

Callers 3

socketInitiatorMethod · 0.80
MONITORMethod · 0.80
index.spec.tsFile · 0.80

Calls 1

addMethod · 0.65

Tested by

no test coverage detected