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

Method Handle

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

Source from the content-addressed store, hash-verified

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