Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
76e2cd70
Commit
76e2cd70
authored
Jul 30, 2014
by
brendandburns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #683 from smarterclayton/slightly_pause_on_return
Slightly pause on requests to allow most to finish
parents
21513b1e
1bdeb058
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
apiserver.go
pkg/apiserver/apiserver.go
+9
-4
apiserver_test.go
pkg/apiserver/apiserver_test.go
+1
-0
operation_test.go
pkg/apiserver/operation_test.go
+1
-0
No files found.
pkg/apiserver/apiserver.go
View file @
76e2cd70
...
...
@@ -59,10 +59,11 @@ func NewNotFoundErr(kind, name string) error {
//
// TODO: consider migrating this to go-restful which is a more full-featured version of the same thing.
type
APIServer
struct
{
prefix
string
storage
map
[
string
]
RESTStorage
ops
*
Operations
mux
*
http
.
ServeMux
prefix
string
storage
map
[
string
]
RESTStorage
ops
*
Operations
mux
*
http
.
ServeMux
asyncOpWait
time
.
Duration
}
// New creates a new APIServer object.
...
...
@@ -74,6 +75,8 @@ func New(storage map[string]RESTStorage, prefix string) *APIServer {
prefix
:
strings
.
TrimRight
(
prefix
,
"/"
),
ops
:
NewOperations
(),
mux
:
http
.
NewServeMux
(),
// Delay just long enough to handle most simple write operations
asyncOpWait
:
time
.
Millisecond
*
25
,
}
// Primary API methods
...
...
@@ -279,6 +282,8 @@ func (s *APIServer) createOperation(out <-chan interface{}, sync bool, timeout t
op
:=
s
.
ops
.
NewOperation
(
out
)
if
sync
{
op
.
WaitFor
(
timeout
)
}
else
if
s
.
asyncOpWait
!=
0
{
op
.
WaitFor
(
s
.
asyncOpWait
)
}
return
op
}
...
...
pkg/apiserver/apiserver_test.go
View file @
76e2cd70
...
...
@@ -396,6 +396,7 @@ func TestCreate(t *testing.T) {
handler
:=
New
(
map
[
string
]
RESTStorage
{
"foo"
:
simpleStorage
,
},
"/prefix/version"
)
handler
.
asyncOpWait
=
0
server
:=
httptest
.
NewServer
(
handler
)
client
:=
http
.
Client
{}
...
...
pkg/apiserver/operation_test.go
View file @
76e2cd70
...
...
@@ -95,6 +95,7 @@ func TestOpGet(t *testing.T) {
handler
:=
New
(
map
[
string
]
RESTStorage
{
"foo"
:
simpleStorage
,
},
"/prefix/version"
)
handler
.
asyncOpWait
=
0
server
:=
httptest
.
NewServer
(
handler
)
client
:=
http
.
Client
{}
...
...
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