Enhancement/redis client compatibility #10
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Redis Client Compatibility
This PR aims to enable the EchoVault server to interface with official Redis clients by adjusting the RESP responses to ones expected by the server.
This was achieved by primarily doing the following things:
Fixing how we read the bytes from the connection to the client. Previously, the
ReadMessage
function in the utils package relied on a blank line character to determine when to terminate the read. This meant that the delimiter sent by the client had to be\r\n\r\n
. Redis clients do not send this delimiter; instead, the RESP message ends with\r\n
.ReadMessage
now accounts for this and can ingest and parse valid RESP commands from Redis clients.Fixing the RESP response sent to the client. Similar to the issue in point 1, the server would send a
\r\n\r\n
delimiter to the client, and the EchoVault client relies on this delimiter to determine the end of the input. Redis clients cannot parse this delimiter as the second\r\n
is interpreted as part of the next stream. This caused the Redis client to fail, with\r
being an unexpected first byte. The EchoVault client has not been updated to handle this change, but Redis clients can now interface with EchoVault.Sending back an empty array for the 'COMMAND DOCS' command. Redis cli client calls a
COMMAND DOCS
as the first command upon connecting. EchoVault returns an empty array to satisfy the Redis client before moving on to other commands. In the future, this command will return detailed documentation of the available EchoVault commands.Pub/Sub Changes
The consumer group feature has been removed to keep the pub/sub module as close to Redis as possible. This may be re-implemented at a future date, but that has yet to be decided.
Currently, the subscribe command accepts a list of channel options to subscribe to and returns an array confirming the subscription to each channel. Non-existent channels are created on the fly.
The module now also includes
PSUBSCRIBE
andPUNSUBSCRIBE
to allow for subscribing/unsubscribing to patterns. Other commands have also been added, namely:These function the same as their Redis equivalents.