mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-05-09 00:33:24 +02:00
fix(poll): fetch task before sleeping to avoid startup delay
- Reorder pollOnce to fetch first and sleep after, matching the original rate.Limiter burst=1 behavior where the first poll returns immediately - Remove unused ReportInterval config field that was never shipped
This commit is contained in:
@@ -157,17 +157,16 @@ func addJitter(d time.Duration) time.Duration {
|
||||
|
||||
func (p *Poller) pollOnce() {
|
||||
for {
|
||||
interval := addJitter(p.calculateInterval())
|
||||
timer := time.NewTimer(interval)
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-p.pollingCtx.Done():
|
||||
timer.Stop()
|
||||
return
|
||||
}
|
||||
|
||||
task, ok := p.fetchTask(p.pollingCtx)
|
||||
if !ok {
|
||||
interval := addJitter(p.calculateInterval())
|
||||
timer := time.NewTimer(interval)
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-p.pollingCtx.Done():
|
||||
timer.Stop()
|
||||
return
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user