add lock on storage
parent
13faf9b4f9
commit
f866592513
|
@ -9,8 +9,8 @@ import (
|
|||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Collection the MongoDB Account collection
|
||||
|
@ -39,6 +39,7 @@ func HandleError(e error, serv int) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
var status bool
|
||||
type Config struct {
|
||||
MongoDB string `json:"mongoURL"`
|
||||
}
|
||||
|
@ -67,15 +68,19 @@ func main() {
|
|||
_, err = RedisClient.Ping().Result()
|
||||
fmt.Printf("Connected to Redis [GO]\n")
|
||||
HandleError(err, 1)
|
||||
status = false
|
||||
|
||||
for {
|
||||
fmt.Printf("Calling handler func [GO]\n")
|
||||
handler()
|
||||
if status == false {
|
||||
handler(&status)
|
||||
time.Sleep(1000000 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handler() {
|
||||
func handler(status* bool) {
|
||||
*status = true
|
||||
cur, err := Collection.Find(context.TODO(), bson.D{})
|
||||
HandleError(err, 0)
|
||||
|
||||
|
@ -84,6 +89,7 @@ func handler() {
|
|||
fmt.Printf("Checking account information for %s\n", cur.Current.Lookup("username").String())
|
||||
time.Sleep(600000 * time.Millisecond)
|
||||
}
|
||||
*status = false
|
||||
}
|
||||
|
||||
func checkAccountSizeAndUpdate(username string, id string) {
|
||||
|
|
Loading…
Reference in New Issue