-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Added a timer goroutine to run for a specific duration and upon expir… #1519
Conversation
…ation sends an os.Interrupt signal which shuts down the recorder and exits the program Signed-off-by: heyyakash <akashsharma2002@gmail.com>
@PranshuSrivastava had to force push to match my local branch to original branch and that led to closing of previous pr. Can you review this one instead |
cmd/record.go
Outdated
@@ -42,7 +42,7 @@ func readRecordConfig(configPath string) (*models.Record, error) { | |||
|
|||
var filters = models.TestFilter{} | |||
|
|||
func (t *Record) GetRecordConfig(path *string, proxyPort *uint32, appCmd *string, appContainer, networkName *string, Delay *uint64, buildDelay *time.Duration, passThroughPorts *[]uint, passThrough *[]models.Filters, configPath string) error { | |||
func (t *Record) GetRecordConfig(path *string, proxyPort *uint32, appCmd *string, appContainer, networkName *string, Delay *uint64, buildDelay *time.Duration, passThroughPorts *[]uint, passThrough *[]models.Filters, configPath string, keployRecorderStopTimer *time.Duration) error { |
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.
This name is too long. Just keep it something simple like "recordTimer"
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.
ok
cmd/record.go
Outdated
@@ -303,6 +308,8 @@ func (r *Record) GetCmd() *cobra.Command { | |||
|
|||
recordCmd.Flags().StringP("command", "c", "", "Command to start the user application") | |||
|
|||
recordCmd.Flags().DurationP("keployRecorderStopTimer", "t", 0, "Command to initiate a timer that automatically stops the Keploy recorder after a specified duration of time") |
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.
Make this also into something briefer like "timer to stop keploy record after the required time".
Signed-off-by: heyyakash <akashsharma2002@gmail.com>
@PranshuSrivastava I've made the changes, please check |
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.
I've tested your changes, they work as intended, just make the following changes.
pkg/service/record/record.go
Outdated
timer := time.After(recordTimer) | ||
select { | ||
case <-timer: | ||
r.Logger.Warn("Time up! Stopping the timer") |
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.
we are stopping keploy not the timer.
cmd/record.go
Outdated
@@ -303,6 +308,8 @@ func (r *Record) GetCmd() *cobra.Command { | |||
|
|||
recordCmd.Flags().StringP("command", "c", "", "Command to start the user application") | |||
|
|||
recordCmd.Flags().DurationP("recordTimer", "t", 0, "Timer to stop keploy recorder after a specified time") |
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.
why is the shorthand of the flag -t? That can confuse the user, either start the name with t or change the shorthand to the first alphabet of the full flag name.
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.
Heyy! so i removed the shorthand entirely and kept it as --recordTimer , keeping the shorthand as -r would lead to ambiguity, So please check
Signed-off-by: heyyakash <akashsharma2002@gmail.com>
@PranshuSrivastava can you please review the new changes? |
@@ -308,7 +308,7 @@ func (r *Record) GetCmd() *cobra.Command { | |||
|
|||
recordCmd.Flags().StringP("command", "c", "", "Command to start the user application") | |||
|
|||
recordCmd.Flags().DurationP("recordTimer", "t", 0, "Timer to stop keploy recorder after a specified time") | |||
recordCmd.Flags().Duration("recordTimer", 0, "Timer to stop keploy recorder after a specified time") |
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.
Why have you removed the code for reading this flag?
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.
heyy! so i removed the shorthand entirely and kept it as --recordTimer , keeping the shorthand as -r would lead to ambiguity,
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.
LGTM
@PranshuSrivastava can you merge then? |
…ation sends an os.Interrupt signal which shuts down the recorder and exits the program
Related Issue
Closes: #1434
Describe the changes you've made
Type of change
Please let us know if any test cases are added
Please describe the tests(if any). Provide instructions how its affecting the coverage.
Describe if there is any unusual behaviour of your code(Write
NA
if there isn't)A clear and concise description of it.
NA
Checklist:
Screenshots (if any)