Add work queue for requests
This commit is contained in:
parent
83b39b15f6
commit
a52c0cc2fd
5 changed files with 193 additions and 74 deletions
|
|
@ -140,7 +140,7 @@ start_concurrent_server :: proc(
|
|||
|
||||
server_thread_proc :: proc(t: ^thread.Thread) {
|
||||
d := (^ServerThreadData)(t.data)
|
||||
listen_and_serve(d.server)
|
||||
server_listen_and_serve(d.server)
|
||||
}
|
||||
|
||||
d := new(ServerThreadData, context.temp_allocator)
|
||||
|
|
@ -201,7 +201,6 @@ assert_endpoint_response :: proc(url: string, expected_response: string) {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
@(test)
|
||||
test_server_general_ok :: proc(t: ^testing.T) {
|
||||
context.logger = log.create_console_logger(.Info)
|
||||
|
|
@ -232,18 +231,22 @@ test_server_general_ok :: proc(t: ^testing.T) {
|
|||
|
||||
t := start_concurrent_server(&server)
|
||||
|
||||
assert_endpoint_response(
|
||||
"http://127.0.0.1:8080/hello/world",
|
||||
"<div>Hello firstworld</div>",
|
||||
)
|
||||
assert_endpoint_response(
|
||||
"http://127.0.0.1:8080/hello/lonely%20world/only",
|
||||
"<div>Hello secondlonely%20world</div>",
|
||||
)
|
||||
assert_endpoint_response(
|
||||
"http://127.0.0.1:8080/hello/world/and/worlds%20friend",
|
||||
"<div>Hello thirdworldandworlds%20friend</div>",
|
||||
)
|
||||
// Try with some load
|
||||
ITERATIONS :: 100
|
||||
for i in 0 ..< ITERATIONS {
|
||||
assert_endpoint_response(
|
||||
"http://127.0.0.1:8080/hello/world",
|
||||
"<div>Hello firstworld</div>",
|
||||
)
|
||||
assert_endpoint_response(
|
||||
"http://127.0.0.1:8080/hello/lonely%20world/only",
|
||||
"<div>Hello secondlonely%20world</div>",
|
||||
)
|
||||
assert_endpoint_response(
|
||||
"http://127.0.0.1:8080/hello/world/and/worlds%20friend",
|
||||
"<div>Hello thirdworldandworlds%20friend</div>",
|
||||
)
|
||||
}
|
||||
|
||||
shutdown_concurrent_server(&server, t)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue