DiceDB / dice

DiceDB is a redis-compliant, in-memory, real-time, and reactive database optimized for modern hardware and for building and scaling truly real-time applications.
https://dicedb.io/
Other
6.7k stars 1.06k forks source link

Command Migration: ('LPUSH', 'RPUSH', 'LPOP', 'RPOP', 'LLEN') #1019

Open AshwinKul28 opened 1 month ago

AshwinKul28 commented 1 month ago

This issue tracks the migration of the mentioned commands - ('LPUSH', 'RPUSH', 'LPOP', 'RPOP', 'LLEN') to make them compatible across the three protocols supported by the Dice database: RESP, HTTP, and WebSocket. DiceDB now supports more than one protocols (Resp/http/websocket). We don't want eval operation of each command to be strictly bound with any of the protocols. Currently eval function return statements of each command is bounded to the RESP protocol.

The migration is required because:

The goal is to make the command logic protocol-independent, allowing all three protocols to call the same core functionality seamlessly.

Requirements

Migration Steps

  1. Analyze Current Implementation

    • Review the current codebase to understand how the command logic is implemented.
  2. Refactor Return Logic

    • Create a new function with the function definition as evalXXX(args []string, store *dstore.Store) *EvalResponse under the file /internal/eval/store_eval.go
    • Analyse return statements of the eval and modify them to send raw types without encoding
    • Use errors in the return statements from /errors/migrated_errors.go file
    • Use perdefined responses from /internal/clientio/resp.go file as RespType variables
  3. Command/Worker specific Changes

    • Make IsMigrated flag to true in the commands information under /internal/eval/commands.go file.
    • Use the newly written eval function against the NewEval parameter in the same command structure.
    • Delete the old eval function from the /internal/eval/eval.go file.
    • Add the migrated command to the /internal/worker/CommandsMeta map and make it's type as SingleShard
  4. Update Unit Tests

    • Refactor existing unit tests to accommodate the new implementation.
    • Add new unit tests if necessary to cover all possible cases.
  5. Integration Tests

    • Run all integration tests to ensure successful migration.
    • Ensure that each protocol (RESP, HTTP, WebSocket) works correctly after migration.

Checklist

Additional Notes

If there are any questions or concerns about this migration, please mention them here.

Related Issues/PRs

ankkyprasad commented 1 month ago

Hi Ashwin, I'd like to work on this issue, Can you please assign this to me?

AshwinKul28 commented 1 month ago

Thanks @ankkyprasad go for it 🚀

AshwinKul28 commented 3 weeks ago

HI @ankkyprasad , I hope you are doing well. Do you happen to have any updates on this? If you've any doubts please let us know on the discord.

ankkyprasad commented 3 weeks ago

Hey @AshwinKul28, I'll start working on it from tonight. Didn't get time this weekends.

AshwinKul28 commented 3 weeks ago

Hi @ankkyprasad hope you are doing well, can you please update the current progress on this task? If you have any blockers feel free to discuss here or on the discord.

ankkyprasad commented 3 weeks ago

Hey @AshwinKul28, I'm working on unittest cases. Will be done by this weekend...

mohit-nagaraj commented 2 weeks ago

Hey @ankkyprasad whts the update

ankkyprasad commented 2 weeks ago

Hey @mohit-nagaraj, you can take this up. I won't be unable to work on this due to some issues.

Aditya-Chowdhary commented 2 weeks ago

Hi, if this issue is available, I would like to work on it.

apoorvyadav1111 commented 2 weeks ago

Hi @Aditya-Chowdhary, thank you for taking this on! Please proceed with the migration steps. Go for it!