Files
wagslane 9be3074de6 first
2023-05-01 15:25:27 -06:00

39 lines
712 B
Go

package main
import (
"fmt"
"time"
)
func waitForDbs(numDBs int, dbChan chan struct{}) {
// ?
}
// don't touch below this line
func test(numDBs int) {
dbChan := getDatabasesChannel(numDBs)
fmt.Printf("Waiting for %v databases...\n", numDBs)
waitForDbs(numDBs, dbChan)
time.Sleep(time.Millisecond * 10) // ensure the last print statement happens
fmt.Println("All databases are online!")
fmt.Println("=====================================")
}
func main() {
test(3)
test(4)
test(5)
}
func getDatabasesChannel(numDBs int) chan struct{} {
ch := make(chan struct{})
go func() {
for i := 0; i < numDBs; i++ {
ch <- struct{}{}
fmt.Printf("Database %v is online\n", i+1)
}
}()
return ch
}