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 { ...@@ -20,7 +20,7 @@ type Queue struct {
// limit specifies number of requests run concurrently // limit specifies number of requests run concurrently
// queueLimit specifies maximum number of requests that can be queued // queueLimit specifies maximum number of requests that can be queued
// if the number of requests is above the limit // if the number of requests is above the limit
func NewQueue(limit, queueLimit int) *Queue { func NewQueue(limit, queueLimit uint) *Queue {
return &Queue{ return &Queue{
busyCh: make(chan struct{}, limit), busyCh: make(chan struct{}, limit),
waitingCh: make(chan struct{}, queueLimit), waitingCh: make(chan struct{}, queueLimit),
......
...@@ -9,8 +9,8 @@ import ( ...@@ -9,8 +9,8 @@ import (
const DefaultTimeout = 30 * time.Second const DefaultTimeout = 30 * time.Second
func QueueRequests(h http.Handler, limit, queueLimit int, queueTimeout time.Duration) http.Handler { func QueueRequests(h http.Handler, limit, queueLimit uint, queueTimeout time.Duration) http.Handler {
if queueLimit == 0 || limit == 0 { if limit == 0 {
return h return h
} }
if queueTimeout == 0 { if queueTimeout == 0 {
......
...@@ -28,7 +28,7 @@ func TestQueueRequests(t *testing.T) { ...@@ -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{}) closeCh := make(chan struct{})
defer close(closeCh) defer close(closeCh)
......
...@@ -28,8 +28,8 @@ type Config struct { ...@@ -28,8 +28,8 @@ type Config struct {
DevelopmentMode bool DevelopmentMode bool
Socket string Socket string
ProxyHeadersTimeout time.Duration ProxyHeadersTimeout time.Duration
APILimit int APILimit uint
APIQueueLimit int APIQueueLimit uint
APIQueueTimeout time.Duration APIQueueTimeout time.Duration
} }
......
...@@ -42,8 +42,8 @@ var documentRoot = flag.String("documentRoot", "public", "Path to static files c ...@@ -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 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 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 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 apiLimit = flag.Uint("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 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") var apiQueueTimeout = flag.Duration("apiQueueDuration", queueing.DefaultTimeout, "Maximum queueing duration of requests")
func main() { 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