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

fix: reset prompt state upon exiting watch mode (issue #15) #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vpsinghg
Copy link
Contributor

@vpsinghg vpsinghg commented Nov 22, 2024

This PR aims to fix issue #15 , where we need to enter one more time after exiting from watch mode to reset dicedb cli.

@vpsinghg
Copy link
Contributor Author

@arpitbbhayani Please review and let me know if there is a better way.

cli/main.go Outdated
@@ -58,7 +58,8 @@ func Run(host string, port int) {
Fn: func(buf *prompt.Buffer) {
if dicedbClient.subscribed {
fmt.Println("Exiting watch mode.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arpitbbhayani I think this message log also should be moved to handleWatchModeExit method.

cli/main.go Outdated
Comment on lines 179 to 180
c.subscribed = false
c.subType = ""
Copy link
Contributor

@lucifercr07 lucifercr07 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would suggest this to be moved to case <-c.subCtx.Done():
The defer function in the watchCommand is not immediately getting executed when cancel() is called and meanwhile the subCtx.Done() channel will unblock and exit the loop. We can reset subscribed and subType immediately on cancel as part of exit itself.

Copy link
Contributor Author

@vpsinghg vpsinghg Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, cancellation message is processed by this watchCommand goroutine asynchronously, right? So LivePrefix method can be executed even before we reset subscribed to false.
This state on which the LivePrefix depends should be reset synchronously.
Let me know in case I am missing something.

@arpitbbhayani
Copy link
Contributor

@vpsinghg can you please rebase the changes with master?

@vpsinghg vpsinghg force-pushed the fix/prompt_reset_on_exit_from_watch_mode branch from b6c0e14 to 3dc3dd5 Compare November 28, 2024 07:41
@vpsinghg
Copy link
Contributor Author

@arpitbbhayani I have rebased with master

@vpsinghg
Copy link
Contributor Author

vpsinghg commented Dec 2, 2024

@arpitbbhayani Can you please review the changes?

@lucifercr07
Copy link
Contributor

@vpsinghg please rebase once with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants