-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
fix: reset prompt state upon exiting watch mode (issue #15) #17
Conversation
@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.") |
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.
@arpitbbhayani I think this message log also should be moved to handleWatchModeExit method.
cli/main.go
Outdated
c.subscribed = false | ||
c.subType = "" |
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.
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.
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.
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.
@vpsinghg can you please rebase the changes with master? |
…chronization for running LivePrefix after subscription state is reset
b6c0e14
to
3dc3dd5
Compare
@arpitbbhayani I have rebased with master |
@arpitbbhayani Can you please review the changes? |
@vpsinghg please rebase once with master. |
This PR aims to fix issue #15 , where we need to enter one more time after exiting from watch mode to reset dicedb cli.