(w *RESPHandle.WriterHandle, args []interface{})
| 57 | } |
| 58 | |
| 59 | func (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 | |
| 97 | func (r *Router) Sync(args []interface{}) error { |
| 98 | cmdType := strings.ToUpper(args[0].(string)) |
nothing calls this directly
no test coverage detected