Commit 06400541 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix compilation errors

parent 9e96ee75
...@@ -23,7 +23,7 @@ type Queue struct { ...@@ -23,7 +23,7 @@ type Queue struct {
func NewQueue(limit, queueLimit uint) *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{}, limit+queueLimit),
} }
} }
...@@ -41,7 +41,9 @@ func (s *Queue) Acquire(timeout time.Duration) (err error) { ...@@ -41,7 +41,9 @@ func (s *Queue) Acquire(timeout time.Duration) (err error) {
} }
defer func() { defer func() {
<-s.waitingCh if err != nil {
<-s.waitingCh
}
}() }()
// fast path: push item to current processed items (non-blocking) // fast path: push item to current processed items (non-blocking)
...@@ -69,5 +71,6 @@ func (s *Queue) Acquire(timeout time.Duration) (err error) { ...@@ -69,5 +71,6 @@ func (s *Queue) Acquire(timeout time.Duration) (err error) {
// It triggers next request to be processed if it's in queue // It triggers next request to be processed if it's in queue
func (s *Queue) Release() { func (s *Queue) Release() {
// dequeue from queue to allow next request to be processed // dequeue from queue to allow next request to be processed
<-s.waitingCh
<-s.busyCh <-s.busyCh
} }
...@@ -32,7 +32,7 @@ func TestNormalRequestProcessing(t *testing.T) { ...@@ -32,7 +32,7 @@ func TestNormalRequestProcessing(t *testing.T) {
// then it runs a number of requests that are going through queue, // then it runs a number of requests that are going through queue,
// we return the response of first finished request, // we return the response of first finished request,
// where status of request can be 200, 429 or 503 // where status of request can be 200, 429 or 503
func testSlowRequestProcessing(count, limit, queueLimit uint, queueTimeout time.Duration) *httptest.ResponseRecorder { func testSlowRequestProcessing(count int, limit, queueLimit uint, queueTimeout time.Duration) *httptest.ResponseRecorder {
pauseCh := make(chan struct{}) pauseCh := make(chan struct{})
defer close(pauseCh) defer close(pauseCh)
......
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