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

Method Handle

IceFireDB-Redis-Proxy/pkg/router/redisNode/router.go:57–93  ·  view source on GitHub ↗
(w *RESPHandle.WriterHandle, args []interface{})

Source from the content-addressed store, hash-verified

55}
56
57func (r *Router) Handle(w *RESPHandle.WriterHandle, args []interface{}) error {
58 defer func() {
59 if r := recover(); r != nil {
60 logrus.Error("handle panic", r)
61 }
62 }()
63 cmdType := strings.ToUpper(string(args[0].([]byte)))
64
65 op, ok := router.OpTable[cmdType]
66
67 if !ok || op.Flag.IsNotAllowed() {
68 return router.WriteError(w, fmt.Errorf(router.ErrUnknownCommand, cmdType))
69 }
70
71 if !op.ArgsVerify(len(args)) {
72 return router.WriteError(w, fmt.Errorf(router.ErrArguments, cmdType))
73 }
74
75 handlers, ok := r.cmd[cmdType]
76 if !ok {
77 handlers = r.cmd[CMDEXEC]
78 }
79 c := r.pool.Get().(*router.Context)
80 defer func() {
81 c.Reset()
82 r.pool.Put(c)
83 }()
84 c.Index = -1
85 c.Writer = w
86 c.Args = args
87 c.Handlers = handlers
88 c.Cmd = cmdType
89 c.Op = op.Flag
90 c.Reply = nil
91
92 return c.Next()
93}
94
95func (r *Router) Sync(args []interface{}) error {
96 cmdType := strings.ToUpper(args[0].(string))

Callers

nothing calls this directly

Calls 7

WriteErrorFunction · 0.92
ErrorMethod · 0.45
IsNotAllowedMethod · 0.45
GetMethod · 0.45
ResetMethod · 0.45
PutMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected