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
3f90655c
Commit
3f90655c
authored
Sep 29, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make apiQueueLimit to be a backlog of requests
parent
945e8b35
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
internal/queueing/queue.go
internal/queueing/queue.go
+1
-1
internal/queueing/queue_test.go
internal/queueing/queue_test.go
+3
-3
internal/queueing/requests_test.go
internal/queueing/requests_test.go
+3
-3
No files found.
internal/queueing/queue.go
View file @
3f90655c
...
...
@@ -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
),
}
}
...
...
internal/queueing/queue_test.go
View file @
3f90655c
...
...
@@ -6,7 +6,7 @@ import (
)
func
TestNormalQueueing
(
t
*
testing
.
T
)
{
q
:=
NewQueue
(
2
,
3
)
q
:=
NewQueue
(
2
,
1
)
err1
:=
q
.
Acquire
(
time
.
Microsecond
)
if
err1
!=
nil
{
t
.
Fatal
(
"we should acquire a new slot"
)
...
...
@@ -31,7 +31,7 @@ func TestNormalQueueing(t *testing.T) {
}
func
TestQueueLimit
(
t
*
testing
.
T
)
{
q
:=
NewQueue
(
1
,
1
)
q
:=
NewQueue
(
1
,
0
)
err1
:=
q
.
Acquire
(
time
.
Microsecond
)
if
err1
!=
nil
{
t
.
Fatal
(
"we should acquire a new slot"
)
...
...
@@ -44,7 +44,7 @@ func TestQueueLimit(t *testing.T) {
}
func
TestQueueProcessing
(
t
*
testing
.
T
)
{
q
:=
NewQueue
(
1
,
2
)
q
:=
NewQueue
(
1
,
1
)
err1
:=
q
.
Acquire
(
time
.
Microsecond
)
if
err1
!=
nil
{
t
.
Fatal
(
"we should acquire a new slot"
)
...
...
internal/queueing/requests_test.go
View file @
3f90655c
...
...
@@ -21,7 +21,7 @@ func slowHttpHandler(closeCh chan struct{}) http.Handler {
func
TestQueueRequests
(
t
*
testing
.
T
)
{
w
:=
httptest
.
NewRecorder
()
h
:=
QueueRequests
(
httpHandler
,
1
,
2
,
time
.
Second
)
h
:=
QueueRequests
(
httpHandler
,
1
,
1
,
time
.
Second
)
h
.
ServeHTTP
(
w
,
nil
)
if
w
.
Code
!=
200
{
t
.
Fatal
(
"QueueRequests should process request"
)
...
...
@@ -51,7 +51,7 @@ func testSlowRequestProcessing(count, limit, queueLimit uint, queueTimeout time.
}
func
TestQueueingTimeout
(
t
*
testing
.
T
)
{
w
:=
testSlowRequestProcessing
(
2
,
1
,
2
,
time
.
Microsecond
)
w
:=
testSlowRequestProcessing
(
2
,
1
,
1
,
time
.
Microsecond
)
if
w
.
Code
!=
503
{
t
.
Fatal
(
"QueueRequests should timeout queued request"
)
...
...
@@ -59,7 +59,7 @@ func TestQueueingTimeout(t *testing.T) {
}
func
TestQueuedRequests
(
t
*
testing
.
T
)
{
w
:=
testSlowRequestProcessing
(
3
,
1
,
2
,
time
.
Minute
)
w
:=
testSlowRequestProcessing
(
3
,
1
,
1
,
time
.
Minute
)
if
w
.
Code
!=
429
{
t
.
Fatal
(
"QueueRequests should return immediately and return too many requests"
)
...
...
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