antirez / RESP3

RESP protocol V3 repository. Contains the specification, and other related resource
229 stars 41 forks source link

Carification of attributes: arity, key uniquity, and permitted key types #35

Open mgravell opened 4 years ago

mgravell commented 4 years ago

Arity

For any (following) element, it seems clear that attributes can be omitted or present, but it isn't explicit whether they can be repeated. For example, we know this is valid:

|1<CR><LF>
    +ttl<CR><LF>
    :3600<CR><LF>
:3<CR><LF>

but is this valid

|1<CR><LF>
    +ttl<CR><LF>
    :3600<CR><LF>
|1<CR><LF>
    +priority<CR><LF>
    :7<CR><LF>
:3<CR><LF>

and if so (my personal preference would be "no, that isn't valid"), is it semantically identical to:

|2<CR><LF>
    +ttl<CR><LF>
    :3600<CR><LF>
    +priority<CR><LF>
    :7<CR><LF>
:3<CR><LF>

or does it need to be possible to tell between the two scenarios?


Uniquity

How is the following to be interpreted?

|2<CR><LF>
    +ttl<CR><LF>
    :3600<CR><LF>
    +ttl<CR><LF>
    :9001<CR><LF>
:3<CR><LF>

is this:


Permitted Key Types

(a lot of this may cross over into map more generally)

In a lot of platforms, it may be hard to reliably implement maps that can take arbitrary types as keys, as the equality semantics are very awkward. In reality, I can see a lot of clients would want to restrict handling to string-like types, as that is what most attributes are going to be keyed as. Now, sure, clients could choose to just treat all keys as blobs, but that has other problems.

As a pragmatic note, it may be sensible to consider whether it is actually required for attributes (and maps?) to allow keys that are, say, integers, doubles, big integers, in the case of attributes, it might even be prudent to limit it to simple strings, i.e. +foo