dice icon indicating copy to clipboard operation
dice copied to clipboard

Command Migration: ('HLEN', 'HSTRLEN', 'HSCAN')

Open AshwinKul28 opened this issue 1 year ago • 13 comments

This issue tracks the migration of the mentioned commands - ('HLEN', 'HSTRLEN', 'HSCAN') 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

  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

  • [ ] 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 avatar Oct 08 '24 19:10 AshwinKul28

I can take this up @AshwinKul28

ayushsatyam146 avatar Oct 09 '24 02:10 ayushsatyam146

Hey @ayushsatyam146 assigned the other one to you!

AshwinKul28 avatar Oct 09 '24 02:10 AshwinKul28

Hi @AshwinKul28. Can i work on this issue?

bagmeg avatar Oct 09 '24 08:10 bagmeg

Hey @bagmeg thanks for the interest! Go for it! 🚀

AshwinKul28 avatar Oct 09 '24 10:10 AshwinKul28

HI @bagmeg , 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.

AshwinKul28 avatar Oct 12 '24 20:10 AshwinKul28

Hi, @bagmeg. Are you working on this? If not, I can take on this.

c-harish avatar Oct 16 '24 19:10 c-harish

Hi. I'm working on it

bagmeg avatar Oct 16 '24 22:10 bagmeg

Hey @bagmeg 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.

AshwinKul28 avatar Oct 17 '24 12:10 AshwinKul28

Hey @bagmeg whts the update

mohit-nagaraj avatar Oct 20 '24 04:10 mohit-nagaraj

Hey @bagmeg whts the update

Hi @mohit-nagaraj. I am on it. In case @bagmeg doesn't update, I will raise.

c-harish avatar Oct 20 '24 05:10 c-harish

Sure @c-harish even i wanted to take this up in case @bagmeg doesn't respond 🥲

mohit-nagaraj avatar Oct 20 '24 05:10 mohit-nagaraj

@c-harish hi. still working on it, but I need more time. If you've finished, please submit it first. I'll look into other issues.

bagmeg avatar Oct 20 '24 05:10 bagmeg

@AshwinKul28 Can you please assign this one to me? I have raised #1162.

@c-harish hi. still working on it, but I need more time. If you've finished, please submit it first. I'll look into other issues.

c-harish avatar Oct 20 '24 08:10 c-harish