mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-25 11:28:03 +08:00
Compare commits
2 Commits
f91a586da8
...
83213d493e
Author | SHA1 | Date | |
---|---|---|---|
|
83213d493e | ||
|
90ed01ed53 |
@ -105,6 +105,7 @@ func (f *Fetcher[V]) loadBuf(buf []byte, hash utils.HashType, updateFile bool) (
|
|||||||
_ = os.Chtimes(f.vehicle.Path(), now, now)
|
_ = os.Chtimes(f.vehicle.Path(), now, now)
|
||||||
}
|
}
|
||||||
f.updatedAt = now
|
f.updatedAt = now
|
||||||
|
f.backoff.Reset() // no error, reset backoff
|
||||||
return lo.Empty[V](), true, nil
|
return lo.Empty[V](), true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +221,10 @@ func (f *Fetcher[V]) updateWithLog() {
|
|||||||
|
|
||||||
func NewFetcher[V any](name string, interval time.Duration, vehicle types.Vehicle, parser Parser[V], onUpdate func(V)) *Fetcher[V] {
|
func NewFetcher[V any](name string, interval time.Duration, vehicle types.Vehicle, parser Parser[V], onUpdate func(V)) *Fetcher[V] {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
minBackoff := 10 * time.Second
|
||||||
|
if interval < minBackoff {
|
||||||
|
minBackoff = interval
|
||||||
|
}
|
||||||
return &Fetcher[V]{
|
return &Fetcher[V]{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
ctxCancel: cancel,
|
ctxCancel: cancel,
|
||||||
@ -231,7 +236,7 @@ func NewFetcher[V any](name string, interval time.Duration, vehicle types.Vehicl
|
|||||||
backoff: slowdown.Backoff{
|
backoff: slowdown.Backoff{
|
||||||
Factor: 2,
|
Factor: 2,
|
||||||
Jitter: false,
|
Jitter: false,
|
||||||
Min: time.Second,
|
Min: minBackoff,
|
||||||
Max: interval,
|
Max: interval,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user