Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
06400541
Commit
06400541
authored
Oct 04, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation errors
parent
9e96ee75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
internal/queueing/queue.go
internal/queueing/queue.go
+5
-2
internal/queueing/requests_test.go
internal/queueing/requests_test.go
+1
-1
No files found.
internal/queueing/queue.go
View file @
06400541
...
...
@@ -23,7 +23,7 @@ type Queue struct {
func
NewQueue
(
limit
,
queueLimit
uint
)
*
Queue
{
return
&
Queue
{
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) {
}
defer
func
()
{
<-
s
.
waitingCh
if
err
!=
nil
{
<-
s
.
waitingCh
}
}()
// fast path: push item to current processed items (non-blocking)
...
...
@@ -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
func
(
s
*
Queue
)
Release
()
{
// dequeue from queue to allow next request to be processed
<-
s
.
waitingCh
<-
s
.
busyCh
}
internal/queueing/requests_test.go
View file @
06400541
...
...
@@ -32,7 +32,7 @@ func TestNormalRequestProcessing(t *testing.T) {
// then it runs a number of requests that are going through queue,
// we return the response of first finished request,
// 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
{})
defer
close
(
pauseCh
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment