MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / handle

Method handle

IceFireDB-PubSub/proxy/handle.go:33–77  ·  view source on GitHub ↗
(conn bareneter.Conn)

Source from the content-addressed store, hash-verified

31)
32
33func (p *Proxy) handle(conn bareneter.Conn) {
34 defer func() {
35 _ = conn.Close()
36 }()
37 localConn := conn.NetConn()
38 localWriteHandle := RESPHandle.NewWriterHandle(localConn)
39 decoder := credis.NewDecoderSize(localConn, 1024)
40 for {
41 resp, err := decoder.Decode()
42 if err != nil {
43 return
44 }
45 if resp.Type != credis.TypeArray {
46 _ = router.WriteError(localWriteHandle, fmt.Errorf(router.ErrUnknownCommand, "cmd"))
47 return
48 }
49
50 respCount := len(resp.Array)
51
52 if respCount < 1 {
53 _ = router.WriteError(localWriteHandle, fmt.Errorf(router.ErrArguments, "cmd"))
54 return
55 }
56
57 if resp.Array[0].Type != credis.TypeBulkBytes {
58 _ = router.WriteError(localWriteHandle, router.ErrCmdTypeWrong)
59 return
60 }
61
62 commandArgs := make([]interface{}, respCount)
63 for i := 0; i < respCount; i++ {
64 commandArgs[i] = resp.Array[i].Value
65 }
66 err = p.router.Handle(localWriteHandle, commandArgs)
67
68 if err != nil {
69 if errors.Is(err, router.ErrLocalWriter) || errors.Is(err, router.ErrLocalFlush) {
70 return
71 }
72 _ = router.WriteError(localWriteHandle, err)
73 logrus.Errorf("redis command exec fail:%s , %v", commandArgs, err)
74 return
75 }
76 }
77}

Callers

nothing calls this directly

Calls 4

WriteErrorFunction · 0.92
CloseMethod · 0.65
HandleMethod · 0.65
DecodeMethod · 0.45

Tested by

no test coverage detected