Skip to content

PUSH type not distinguishable from ARRAY type in RESP3 #128

@stereobutter

Description

@stereobutter

RESP3 introduced the PUSH type for transmitting out of band data to a client (such as pubsub messages, client tracking invalidation events etc.). Except for being its own type (identified by the > symbol) PUSH is the same as ARRAY.

Currently using hiredis-py parsing a PUSH message returns a list, same as parsing an ARRAY.

example = (
    ">4\r\n"  # push array with 4 elements
    "+pubsub\r\n" 
    "+message\r\n"
    "+somechannel\r\n"
    "+this is the message\r\n"
)

reader.feed(example)
data = reader.gets()
assert type(data) is list

This makes it impossible for a client to differentiate PUSH and ARRAY messages. As PUSH messages may be interleaved with regular replies (such as when using CLIENT TRACKING on the same connection) it is important for a client to be able and differentiate them.

It appears upstream hiredis already supports the PUSH type

For hiredis-py PUSH messages clould use a subclass of list i.e. something like type('push', (list,), {}).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions