MCPcopy
hub / github.com/redis/go-redis / readMonitor

Method readMonitor

command.go:8037–8058  ·  view source on GitHub ↗
(rd *proto.Reader, cancel context.CancelFunc)

Source from the content-addressed store, hash-verified

8035}
8036
8037func (cmd *MonitorCmd) readMonitor(rd *proto.Reader, cancel context.CancelFunc) error {
8038 for {
8039 cmd.mu.Lock()
8040 st := cmd.status
8041 pk, _ := rd.Peek(1)
8042 cmd.mu.Unlock()
8043 if len(pk) != 0 && st == monitorStatusStart {
8044 cmd.mu.Lock()
8045 line, err := rd.ReadString()
8046 cmd.mu.Unlock()
8047 if err != nil {
8048 return err
8049 }
8050 cmd.ch <- line
8051 }
8052 if st == monitorStatusStop {
8053 cancel()
8054 break
8055 }
8056 }
8057 return nil
8058}
8059
8060func (cmd *MonitorCmd) Start() {
8061 cmd.mu.Lock()

Callers 1

readReplyMethod · 0.95

Calls 2

ReadStringMethod · 0.80
PeekMethod · 0.45

Tested by

no test coverage detected