Commit 945e8b35 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Make apiLimit and apiQueueLimit to be of type uint

parent 3ccf29d4
......@@ -20,7 +20,7 @@ type Queue struct {
// limit specifies number of requests run concurrently
// queueLimit specifies maximum number of requests that can be queued
// if the number of requests is above the limit
func NewQueue(limit, queueLimit int) *Queue {
func NewQueue(limit, queueLimit uint) *Queue {
return &Queue{
busyCh: make(chan struct{}, limit),
waitingCh: make(chan struct{}, queueLimit),
......
......@@ -9,8 +9,8 @@ import (
const DefaultTimeout = 30 * time.Second
func QueueRequests(h http.Handler, limit, queueLimit int, queueTimeout time.Duration) http.Handler {
if queueLimit == 0 || limit == 0 {
func QueueRequests(h http.Handler, limit, queueLimit uint, queueTimeout time.Duration) http.Handler {
if limit == 0 {
return h
}
if queueTimeout == 0 {
......
......@@ -28,7 +28,7 @@ func TestQueueRequests(t *testing.T) {
}
}
func testSlowRequestProcessing(count, limit, queueLimit int, queueTimeout time.Duration) *httptest.ResponseRecorder {
func testSlowRequestProcessing(count, limit, queueLimit uint, queueTimeout time.Duration) *httptest.ResponseRecorder {
closeCh := make(chan struct{})
defer close(closeCh)
......
......@@ -28,8 +28,8 @@ type Config struct {
DevelopmentMode bool
Socket string
ProxyHeadersTimeout time.Duration
APILimit int
APIQueueLimit int
APILimit uint
APIQueueLimit uint
APIQueueTimeout time.Duration
}
......
......@@ -42,8 +42,8 @@ var documentRoot = flag.String("documentRoot", "public", "Path to static files c
var proxyHeadersTimeout = flag.Duration("proxyHeadersTimeout", 5*time.Minute, "How long to wait for response headers when proxying the request")
var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets from Rails app")
var secretPath = flag.String("secretPath", "./.gitlab_workhorse_secret", "File with secret key to authenticate with authBackend")
var apiLimit = flag.Int("apiLimit", 0, "Number of API requests allowed at single time")
var apiQueueLimit = flag.Int("apiQueueLimit", 0, "Number of API requests allowed to be queued")
var apiLimit = flag.Uint("apiLimit", 0, "Number of API requests allowed at single time")
var apiQueueLimit = flag.Uint("apiQueueLimit", 0, "Number of API requests allowed to be queued")
var apiQueueTimeout = flag.Duration("apiQueueDuration", queueing.DefaultTimeout, "Maximum queueing duration of requests")
func main() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment