Skip to content

Instantly share code, notes, and snippets.

@alidevhere
Last active September 23, 2022 15:05
Show Gist options
  • Save alidevhere/596e7ebc751acf8fcea23b6dfa44a9b0 to your computer and use it in GitHub Desktop.
Save alidevhere/596e7ebc751acf8fcea23b6dfa44a9b0 to your computer and use it in GitHub Desktop.
func sleepForWait(t time.Duration) {
for startTime := time.Now(); time.Since(startTime) < t; time.Sleep(10 * time.Second) {
if !*IsCampaigRunning {
// We use logrus for logging
logrus.Info("LEFT SLEEPING !!! IMMEDIATELY STOPING CAMPAIGNS PROCESSING")
return
}
}
}
//Now we can just call it to wait for 5 min
sleepForWait(5 * time.Minute)
//while waiting we are also checking if we need to stop waiting and just stop process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment