Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/redis client compatibility #10

Merged
merged 12 commits into from
Feb 28, 2024

Conversation

kelvinmwinuka
Copy link
Collaborator

@kelvinmwinuka kelvinmwinuka commented Feb 28, 2024

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:

  1. 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.

  2. 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.

  3. 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 and PUNSUBSCRIBE to allow for subscribing/unsubscribing to patterns. Other commands have also been added, namely:

  1. PUBSUB CHANNELS
  2. PUBSUB NUMPAT
  3. PUBSUB NUMSUB

These function the same as their Redis equivalents.

@kelvinmwinuka kelvinmwinuka added the enhancement New feature or request label Feb 28, 2024
@kelvinmwinuka kelvinmwinuka self-assigned this Feb 28, 2024
@kelvinmwinuka kelvinmwinuka linked an issue Feb 28, 2024 that may be closed by this pull request
@kelvinmwinuka kelvinmwinuka merged commit dbeacc7 into main Feb 28, 2024
1 check passed
@kelvinmwinuka kelvinmwinuka deleted the enhancement/redis-client-compatibility branch February 28, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compatibility with Redis Clients
1 participant