Last active
September 23, 2022 15:05
-
-
Save alidevhere/596e7ebc751acf8fcea23b6dfa44a9b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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