28 lines
411 B
Go
28 lines
411 B
Go
package busi
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
USER_LOGIN = "user.login"
|
|
SOCIATY_MINE = "sociaty.mine"
|
|
SOCIATY_LIST = "sociaty.list"
|
|
)
|
|
|
|
func Sleep(min, max time.Duration) {
|
|
ulit := int64(max - min)
|
|
t := time.Duration(rand.Int63n(ulit)) + min
|
|
time.Sleep(t)
|
|
}
|
|
|
|
func Retry(count int, f func() bool) {
|
|
for i := 0; i < count; i++ {
|
|
if f() {
|
|
break
|
|
}
|
|
Sleep(time.Second*1, time.Second*5)
|
|
}
|
|
}
|