Command Migration: ('JSON.ARRAPPEND', 'JSON.ARRLEN', 'JSON.ARRPOP')
This issue tracks the migration of the mentioned commands - ('JSON.ARRAPPEND', 'JSON.ARRLEN', 'JSON.ARRPOP') 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 current implementation is specific to the RESP protocol
- Evaluation functions of each command must be refactored to ensure protocol-agnostic behavior.
- Evaluation functions should return raw responses instead of protocol specific responses.
The goal is to make the command logic protocol-independent, allowing all three protocols to call the same core functionality seamlessly.
Requirements
- Refactor the evaluation function of
[Command Name]to be generic. - Ensure the evaluation function does not include protocol-specific logic.
Migration Steps
-
Analyze Current Implementation
- Review the current codebase to understand how the command logic is implemented.
-
Refactor Return Logic
- Create a new function with the function definition as
evalXXX(args []string, store *dstore.Store) *EvalResponseunder 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.gofile - Use perdefined responses from
/internal/clientio/resp.gofile as RespType variables
- Create a new function with the function definition as
-
Command/Worker specific Changes
- Make
IsMigratedflag to true in the commands information under/internal/eval/commands.gofile. - Use the newly written eval function against the
NewEvalparameter in the same command structure. - Delete the old eval function from the
/internal/eval/eval.gofile. - Add the migrated command to the
/internal/worker/CommandsMetamap and make it's type asSingleShard
- Make
-
Update Unit Tests
- Refactor existing unit tests to accommodate the new implementation.
- Add new unit tests if necessary to cover all possible cases.
-
Integration Tests
- Run all integration tests to ensure successful migration.
- Ensure that each protocol (RESP, HTTP, WebSocket) works correctly after migration.
Checklist
- [ ] Migrated the evalXXX function with the latest definition
- [ ] Update or add unit tests for the new implementation.
- [ ] All unit tests pass successfully.
- [ ] Ensure all integration tests pass successfully.
Additional Notes
- Describe any edge cases that need to be handled in the generic function.
- Mention any protocol-specific optimizations required in wrappers.
If there are any questions or concerns about this migration, please mention them here.
Related Issues/PRs
- Sample implementation for the Get, Set, GetSet and SetEx can be found in this Pull Request.
@AshwinKul28, @lucifercr07 @JyotinderSingh I would love to work on this. Please assign this to me
Hey @surya0180 assigned the other one to you. Thanks!
@AshwinKul28 - please assign this to me.
@psrvere I believe you have other issues assigned already, thanks for your interest. Let's give other folks chance to contribute.
@lucifercr07 can i pick this?
@srivastava-yash I see you have made great progress in the other issue thats currently assigned to you. I am sure you will be able to raise a PR on this much faster. Please feel free to reach out to me or @AshwinKul28 if you have any questions or concerns.
@lucifercr07 can i pick this?
@srivastava-yash are you still working on this issue?
@srivastava-yash are you still working on this issue?
@tarun-29 the PR for this is ready. The task took a little longer as there was an error in HTTP response writing. So once that PR got merged, I made changes here and its up for review currently. Link -> https://github.com/DiceDB/dice/pull/1062