Nethack Launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
557 B

package main
import (
"fmt"
"time"
"gopkg.in/redis.v5"
)
func startWatcher(username, timestamp string, redisClient *redis.Client) chan struct{} {
// create initial keys
redisClient.SAdd("inprogress", username)
redisClient.Set(fmt.Sprintf("inprogress:%s", username), timestamp, 0)
ch := make(chan struct{})
// enter inital inprogress yet
go func() {
for {
select {
case <-ch:
return
default:
redisClient.Expire(fmt.Sprintf("inprogress:%s", username), 10*time.Second)
time.Sleep(8 * time.Second)
}
}
}()
return ch
}