2021-08-11 10:35:51 +00:00
|
|
|
package backend
|
|
|
|
|
|
|
|
import (
|
2021-08-11 11:09:08 +00:00
|
|
|
"time"
|
|
|
|
|
2021-08-18 16:59:51 +00:00
|
|
|
"github.com/MedzikUser/go-utils/common"
|
2021-08-11 10:35:51 +00:00
|
|
|
"gitlab.com/gaming0skar123/go/pingbot/database/mongo"
|
|
|
|
)
|
|
|
|
|
|
|
|
var cacheURL []string
|
|
|
|
|
2021-08-11 11:09:08 +00:00
|
|
|
func cache(retry int) {
|
2021-08-11 10:35:51 +00:00
|
|
|
cacheURL = cacheURL[:0]
|
|
|
|
|
|
|
|
results, err := mongo.GetAll()
|
2021-08-18 16:59:51 +00:00
|
|
|
if common.CheckErr(err, "get documents from db") {
|
2021-08-11 11:09:08 +00:00
|
|
|
if retry == 5 {
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
cache(retry + 1)
|
|
|
|
} else {
|
|
|
|
return
|
|
|
|
}
|
2021-08-11 10:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, value := range results {
|
|
|
|
cacheURL = append(cacheURL, value.URL)
|
|
|
|
}
|
|
|
|
}
|