MCPcopy Create free account
hub / github.com/PostHog/duckgres / tryReuseIdleAssigned

Method tryReuseIdleAssigned

controlplane/org_reserved_pool.go:304–320  ·  view source on GitHub ↗

tryReuseIdleAssigned returns an already-assigned, idle (Hot) worker of the requested shape with its session count bumped, or nil if none is available.

(profile *WorkerProfile)

Source from the content-addressed store, hash-verified

302// WorkerCount returns the number of workers this CP currently has assigned to
303// the org that count against MaxWorkers (hot-idle workers are excluded — they're
304// parked for reclaim and don't consume the cap budget, same as atOrgWorkerCap).
305// This is the per-CP local view; the admin layer sums it across replicas (a
306// worker is owned by exactly one CP) for the Overview per-org load bar.
307func (p *OrgReservedPool) WorkerCount() int {
308 p.shared.mu.Lock()
309 defer p.shared.mu.Unlock()
310 return p.assignedWorkerCountLocked()
311}
312
313// tryReuseIdleAssigned returns an already-assigned, idle (Hot) worker of the
314// requested shape with its session count bumped, or nil if none is available.
315func (p *OrgReservedPool) tryReuseIdleAssigned(profile *WorkerProfile) *ManagedWorker {
316 p.shared.mu.Lock()
317 defer p.shared.mu.Unlock()
318 if p.shared.shuttingDown {
319 return nil
320 }
321 p.shared.cleanDeadWorkersLocked()
322 idle := p.findIdleAssignedWorkerLocked(profile)
323 if idle == nil {

Callers 2

AcquireWorkerMethod · 0.95
acquireDecisionMethod · 0.95

Calls 2

Tested by

no test coverage detected