mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-05-08 16:23:23 +02:00
refactor: use single poller with semaphore-based capacity control
Previously, capacity=N spawned N independent polling goroutines, each making FetchTask RPCs to the Gitea server concurrently. This caused unnecessary connection load on the server proportional to the runner's capacity setting. Replace the N-goroutine model with a single polling loop that uses a buffered channel as a semaphore to control concurrent task execution. The poller acquires a capacity slot before fetching; when at capacity, it blocks without issuing RPCs. Fetched tasks are dispatched to independent goroutines that release their slot on completion. Also fix a pre-existing bug in Shutdown() where the timeout branch used a blocking receive on p.done instead of a non-blocking select, which prevented shutdownJobs() from ever being called on timeout. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,7 +89,7 @@ var (
|
||||
Namespace: Namespace,
|
||||
Subsystem: "poll",
|
||||
Name: "backoff_seconds",
|
||||
Help: "Last observed polling backoff interval. With Capacity > 1, reflects whichever worker wrote last.",
|
||||
Help: "Last observed polling backoff interval in seconds.",
|
||||
})
|
||||
|
||||
JobsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
|
||||
Reference in New Issue
Block a user