Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>
}
}
return &Client{
- Client: hc,
- Scheme: ctrlURL.Scheme,
- APIHost: ctrlURL.Host,
- Insecure: cluster.TLS.Insecure,
- Timeout: 5 * time.Minute,
+ Client: hc,
+ Scheme: ctrlURL.Scheme,
+ APIHost: ctrlURL.Host,
+ Insecure: cluster.TLS.Insecure,
+ Timeout: 5 * time.Minute,
+ requestLimiter: requestLimiter{maxlimit: int64(cluster.API.MaxConcurrentRequests / 4)},
}, nil
}
type requestLimiter struct {
current int64
limit int64
+ maxlimit int64
lock sync.Mutex
cond *sync.Cond
quietUntil time.Time
if max := rl.current * 2; max < rl.limit {
rl.limit = max
}
+ if rl.maxlimit > 0 && rl.maxlimit < rl.limit {
+ rl.limit = rl.maxlimit
+ }
rl.cond.Broadcast()
}
return false