mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
19 lines
437 B
Go
19 lines
437 B
Go
package network
|
|
|
|
import "time"
|
|
|
|
const retry = 10 * time.Second
|
|
|
|
type Retry struct {
|
|
t time.Duration
|
|
fail bool
|
|
}
|
|
|
|
func NewRetry() Retry {
|
|
return Retry{t: retry}
|
|
}
|
|
|
|
func (r *Retry) Fail() *Retry { r.fail = true; time.Sleep(r.t); return r }
|
|
func (r *Retry) Multiply(x int) { r.t *= time.Duration(x) }
|
|
func (r *Retry) Success() { r.t = retry; r.fail = false }
|
|
func (r *Retry) Time() time.Duration { return r.t }
|