arana-db / arana-db/kiwi-cpp

【长期工作】兼容 Redis 错误码规范

Open
#22 3 comments 0 reactions 1 assignee Assigned to @lqxhub View on GitHub
✏️ Feature
Dominant language
C++
Stars
49
Forks
8
PR merge metrics
No merged PRs in 30d

Description

### Which kiwi functionalities are relevant/related to the feature request?

_No response_

### Description

### Is this a regression?

Yes

### Description

RESP 有特殊类型来处理错误。errors类型除了首字符是减号 '-'不是加号以外,其它跟简单字符串一样。RESP中简单字符和错误的真正区别是:错误被客户端当作异常处理,组成错误类型的字符串是错误消息自身。

基本格式如下:

```
"-Error message\r\n"
```

错误应答只在发生异常时发送,例如,要执行命令的参数数据类型不匹配或者命令不存在等。当收到错误返回时,客户端lib应该抛出一个异常。

错误返回例子:

```
-ERR unknown command 'foobar'
-WRONGTYPE Operation against a key holding the wrong kind of value
```

从"-"后面第一个单词起,直到第一个空格或者换行,表示返回的错误类型。这是Redis的一种约定,并不是RESP协议的要求。

ERR 是一个通用错误, 而 WRONGTYPE 是表示更具体的错误,意味着客户端在错误的数据类型上执行操作。这被叫做错误前缀(Error Prefix), 使客户端不用依赖具体错误消息就知道返回的错误类型,错误消息可能会随着时间而变化。

参考文档:https://redis.com.cn/topics/protocol.html

### Please provide a link to a minimal reproduction of the bug

_No response_

### Screenshots or videos

![images](https://camo.githubusercontent.com/3f51b5a32e6e5d5adabdebc5ef968150bdabc8d17a8dc1a535b8fb255d2165d0/68747470733a2f2f67772e616c697061796f626a656374732e636f6d2f7a6f732f616e7466696e63646e2f79396b776737445643642f726570726f647563652e676966)

### Please provide the version you discovered this bug in (check about page for version information)

_No response_

### Anything else?

_No response_

### Proposed solution

_No response_

### Alternatives considered

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.