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

Method Handle

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

Source from the content-addressed store, hash-verified

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