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

Method handle

internal_maint_notif_test.go:166–192  ·  view source on GitHub ↗
(c net.Conn)

Source from the content-addressed store, hash-verified

164}
165
166func (s *mockRESP2Server) handle(c net.Conn) {
167 defer c.Close()
168 r := bufio.NewReader(c)
169 for {
170 args, err := readRESPCommand(r)
171 if err != nil {
172 return
173 }
174 if len(args) == 0 {
175 continue
176 }
177 name := strings.ToUpper(args[0])
178 full := name
179 if len(args) > 1 {
180 full = name + " " + strings.ToUpper(args[1])
181 }
182 s.mu.Lock()
183 s.commands = append(s.commands, full)
184 s.mu.Unlock()
185
186 if name == "HELLO" {
187 _, _ = c.Write([]byte("-ERR unknown command 'hello'\r\n"))
188 continue
189 }
190 _, _ = c.Write([]byte("+OK\r\n"))
191 }
192}
193
194func startMockRESP2Server(t *testing.T) *mockRESP2Server {
195 t.Helper()

Callers 1

startMockRESP2ServerFunction · 0.95

Calls 3

readRESPCommandFunction · 0.85
CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected