-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
#182: Refactor command handling for maintainability #170
#182: Refactor command handling for maintainability #170
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, some minor changes requested.
@yashs360 implemented the changes you had mentioned. please review and lmk of any improvements. Tests(both unit and integration) are working correctly with the changes. |
@kakdeykaushik @yashs360 The Eval attribute of the DiceCmd struct should be an interface instead of a function type. I think the current attributes of the function type are not sufficient to satisfy all future use cases. Using interfaces as the function's input and output would help provide extensibility for future changes as well. One basic distinction I see in the current system is that some commands require only the args whereas some commands require the args along with the connection information. This will also allow us to define commands in different packages as well as long as the objects satisfy the interface requirements. |
Thanks for the inputs and suggestions, Gaurav. Maybe we can do that as a separate effort when it starts to become a problem instead of prematurely making it generic. |
Thanks for the contribution @kakdeykaushik, and for the review @yashs360. Merging this. |
#182
Dice cmds via struct
Summary of change:
Designed a struct to implement dice commands
Implementation details:
DiceCmdMeta
encapsulates information about a dice command. A mapmap[string]DiceCmdMeta{}
stores all theDiceCmdMeta
objects and acts as a source of truth for all the commands.Eval
method contains business logic of the command.PING
. This change is taken from Redis (refer img below)Client
struct are handled separately infunc executeCommand
as it was earlier. Handling them gracefully is a topic of discussion.Info
andDocs
are kept placeholder and will be accomplished in Add support forCOMMAND INFO
command #148 and Add support forCOMMAND DOCS
command #146 respectively.Redis reference:
Note - changes in
core/eval.go
be better viewed in spit mode