(conn net.Conn, log *redisCommandLog, handler func([]string) string)
| 386 | } |
| 387 | |
| 388 | func serveRedisCommandTestConn(conn net.Conn, log *redisCommandLog, handler func([]string) string) { |
| 389 | defer func() { |
| 390 | _ = conn.Close() |
| 391 | }() |
| 392 | reader := bufio.NewReader(conn) |
| 393 | for { |
| 394 | args, errRead := readRedisCommand(reader) |
| 395 | if errRead != nil { |
| 396 | return |
| 397 | } |
| 398 | log.Append(args) |
| 399 | response := "+OK\r\n" |
| 400 | if handler != nil { |
| 401 | response = handler(args) |
| 402 | } |
| 403 | if _, errWrite := io.WriteString(conn, response); errWrite != nil { |
| 404 | return |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func readRedisCommand(reader *bufio.Reader) ([]string, error) { |
| 410 | line, errRead := reader.ReadString('\n') |
no test coverage detected