This commit is contained in:
wagslane
2023-05-01 15:25:27 -06:00
parent f8912668b8
commit 9be3074de6
868 changed files with 58698 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
package main
import (
"fmt"
"time"
)
func saveBackups(snapshotTicker, saveAfter <-chan time.Time) {
for {
select {
case <-snapshotTicker:
takeSnapshot()
case <-saveAfter:
saveSnapshot()
return
default:
waitForData()
time.Sleep(500 * time.Millisecond)
}
}
}
// TEST SUITE - Don't touch below this line
func takeSnapshot() {
fmt.Println("Taking a backup snapshot...")
}
func saveSnapshot() {
fmt.Println("All backups saved!")
}
func waitForData() {
fmt.Println("Nothing to do, waiting...")
}
func test() {
snapshotTicker := time.Tick(800 * time.Millisecond)
saveAfter := time.After(2800 * time.Millisecond)
saveBackups(snapshotTicker, saveAfter)
fmt.Println("===========================")
}
func main() {
test()
}