Currently RESP3 specification allows to encode the same data types in alternative ways because of their different semantic meaning. For example:
- A map data can be encoded as: (1) a Map type; or (2) as a Push type; or as (3) Attributes type.
- An array can be encoded as: (1) Array type; or (2) Set type.
- A string can be encoded as string as one of the many String types or as an Error type.
- Simple string and Simple error; and Bulk string and Bulk error - are the same data types with different semantic meaning.
Then each type has also a streamed version. This leads to an explosion of types.
In CBOR this problem is solved by the tag type. A tag can be wrapped around any other type.
Proposal
Add ability to tag any RESP type. A tag will attach a semantic meaning to the type, but will not change its data type.
Syntax of a tag:
)<tag>\r\n
<another-resp-node>
For example, below is a tag with value 123 wrapped around a string abc:
The value of a tag, like 123, can be any number. Some numbers would have a reserved meaning, for example:
- 1 - push tag
- 2 - attributes tag
- 3 - set tag
- 4 - error
- 5 - UTF-8 text
This way attributes message can be encoded as a Map, instead of adding a new Attributes type:
Instead of:
Alternatively, to save resources, a tag could be specified without the \r\n separator:
Omitting \r\n for tags could be justified because the tag is not a separate data type, it is part of the node it is attached to, it just specifies the semantic meaning of that node.
Push:
instead of:
Set:
instead of
Error:
instead of
Bulk error:
instead of
Verbatim error
Streaming error
)4$?\r\n
;3\r\n
ERR\r\n
;0\r\n
Text guaranteed to be UTF-8:
Currently RESP3 specification allows to encode the same data types in alternative ways because of their different semantic meaning. For example:
Then each type has also a streamed version. This leads to an explosion of types.
In CBOR this problem is solved by the tag type. A tag can be wrapped around any other type.
Proposal
Add ability to tag any RESP type. A tag will attach a semantic meaning to the type, but will not change its data type.
Syntax of a tag:
For example, below is a tag with value
123wrapped around a stringabc:The value of a tag, like
123, can be any number. Some numbers would have a reserved meaning, for example:This way attributes message can be encoded as a Map, instead of adding a new Attributes type:
Instead of:
Alternatively, to save resources, a tag could be specified without the
\r\nseparator:Omitting
\r\nfor tags could be justified because the tag is not a separate data type, it is part of the node it is attached to, it just specifies the semantic meaning of that node.Push:
instead of:
Set:
instead of
Error:
instead of
Bulk error:
instead of
Verbatim error
Streaming error
Text guaranteed to be UTF-8: