itsi 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +2 -2
- data/README.md +8 -0
- data/crates/itsi_error/Cargo.toml +1 -1
- data/crates/itsi_rb_helpers/Cargo.toml +1 -1
- data/crates/itsi_scheduler/Cargo.toml +1 -1
- data/crates/itsi_server/Cargo.toml +1 -1
- data/crates/itsi_server/src/default_responses/mod.rs +3 -0
- data/crates/itsi_server/src/ruby_types/itsi_http_request.rs +15 -10
- data/crates/itsi_server/src/ruby_types/itsi_http_response.rs +2 -2
- data/crates/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +6 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs +13 -7
- data/crates/itsi_server/src/server/thread_worker.rs +4 -1
- data/docs/content/itsi_scheduler/_index.md +31 -1
- data/examples/hybrid_scheduler_mode/Itsi.rb +60 -0
- data/examples/hybrid_scheduler_mode/config.ru +9 -0
- data/examples/hybrid_scheduler_mode/slow_service/Itsi.rb +12 -0
- data/gems/scheduler/Cargo.lock +1 -1
- data/gems/scheduler/lib/itsi/schedule_refinement.rb +96 -0
- data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
- data/gems/scheduler/lib/itsi/scheduler.rb +1 -28
- data/gems/server/Cargo.lock +1 -1
- data/gems/server/lib/itsi/server/config/config_helpers.rb +5 -2
- data/gems/server/lib/itsi/server/config/middleware/endpoint/delete.rb +3 -2
- data/gems/server/lib/itsi/server/config/middleware/endpoint/endpoint.rb +14 -3
- data/gems/server/lib/itsi/server/config/middleware/endpoint/get.rb +3 -2
- data/gems/server/lib/itsi/server/config/middleware/endpoint/patch.rb +3 -2
- data/gems/server/lib/itsi/server/config/middleware/endpoint/post.rb +3 -2
- data/gems/server/lib/itsi/server/config/middleware/endpoint/put.rb +3 -2
- data/gems/server/lib/itsi/server/config/middleware/rackup_file.md +18 -0
- data/gems/server/lib/itsi/server/config/middleware/rackup_file.rb +2 -0
- data/gems/server/lib/itsi/server/config/middleware/run.md +20 -1
- data/gems/server/lib/itsi/server/config/middleware/run.rb +2 -0
- data/gems/server/lib/itsi/server/config/options/ruby_thread_request_backlog_size.md +18 -0
- data/gems/server/lib/itsi/server/config/options/ruby_thread_request_backlog_size.rb +19 -0
- data/gems/server/lib/itsi/server/config/options/scheduler_threads.md +7 -0
- data/gems/server/lib/itsi/server/config.rb +3 -0
- data/gems/server/lib/itsi/server/rack_interface.rb +5 -6
- data/gems/server/lib/itsi/server/version.rb +1 -1
- data/gems/server/test/options/ruby_thread_request_backlog_size.rb +37 -0
- data/gems/server/test/rack/test_rack_server.rb +59 -0
- data/lib/itsi/version.rb +1 -1
- data/tasks.txt +4 -0
- metadata +8 -3
- data/gems/scheduler/sig/itsi_scheduler.rbs +0 -4
- data/gems/server/sig/itsi_server.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9069ae3d194e76dc4c4451d6506594a2a3e3789541b546a31dd3703a172f4e32
|
4
|
+
data.tar.gz: 6aacbd0351095bbde2e6db7c943bcd2444715519b079af2880c93cd5f623572f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36dcaf525c6852659d11c98f2d7813e4f01f86d934508a2ed45f071004f50fe6faee7a921ff9395bbc02198b10e8dc68887415781de3ae53aa3e90019a62f60e
|
7
|
+
data.tar.gz: ac990a66a605e5da8bec5f8bf26f51859ab50a1e4d8f50d95c9c4bf7c2ce6aefa0a882db1e7ef06593ab97ea4210e0faebe98f2a5d5001d9431fda8b1cf06c51
|
data/Cargo.lock
CHANGED
@@ -1644,7 +1644,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
|
1644
1644
|
|
1645
1645
|
[[package]]
|
1646
1646
|
name = "itsi-scheduler"
|
1647
|
-
version = "0.2.
|
1647
|
+
version = "0.2.12"
|
1648
1648
|
dependencies = [
|
1649
1649
|
"bytes",
|
1650
1650
|
"derive_more",
|
@@ -1662,7 +1662,7 @@ dependencies = [
|
|
1662
1662
|
|
1663
1663
|
[[package]]
|
1664
1664
|
name = "itsi-server"
|
1665
|
-
version = "0.2.
|
1665
|
+
version = "0.2.12"
|
1666
1666
|
dependencies = [
|
1667
1667
|
"argon2",
|
1668
1668
|
"async-channel",
|
data/README.md
CHANGED
@@ -104,3 +104,11 @@ You can also run gem-specific variants of the above. E.g.
|
|
104
104
|
* `rake server:test` or `rake scheduler:test`
|
105
105
|
* `rake server:compile` or `rake scheduler:compile`
|
106
106
|
* `rake server:build` or `rake scheduler:build`
|
107
|
+
|
108
|
+
|
109
|
+
### Contributing
|
110
|
+
Developer Certificate of Origin
|
111
|
+
|
112
|
+
By submitting a pull-request you certify that:
|
113
|
+
1. The contribution is your original work or you have the right to submit it;
|
114
|
+
2. You have read and understood the [Developer Certificate of Origin](https://developercertificate.org/) and you accept it.
|
@@ -9,3 +9,6 @@ pub static NOT_FOUND_RESPONSE: LazyLock<ErrorResponse> = LazyLock::new(ErrorResp
|
|
9
9
|
|
10
10
|
pub static INTERNAL_SERVER_ERROR_RESPONSE: LazyLock<ErrorResponse> =
|
11
11
|
LazyLock::new(ErrorResponse::internal_server_error);
|
12
|
+
|
13
|
+
pub static SERVICE_UNAVAILABLE_RESPONSE: LazyLock<ErrorResponse> =
|
14
|
+
LazyLock::new(ErrorResponse::service_unavailable);
|
@@ -22,6 +22,7 @@ use super::{
|
|
22
22
|
itsi_http_response::ItsiHttpResponse,
|
23
23
|
};
|
24
24
|
use crate::{
|
25
|
+
default_responses::{INTERNAL_SERVER_ERROR_RESPONSE, SERVICE_UNAVAILABLE_RESPONSE},
|
25
26
|
server::{
|
26
27
|
byte_frame::ByteFrame,
|
27
28
|
http_message_types::{HttpRequest, HttpResponse},
|
@@ -186,16 +187,20 @@ impl ItsiHttpRequest {
|
|
186
187
|
} else {
|
187
188
|
&context.sender
|
188
189
|
};
|
189
|
-
match sender
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
190
|
+
match sender.try_send(RequestJob::ProcessHttpRequest(request, app)) {
|
191
|
+
Err(err) => match err {
|
192
|
+
async_channel::TrySendError::Full(_) => {
|
193
|
+
Ok(SERVICE_UNAVAILABLE_RESPONSE
|
194
|
+
.to_http_response(context.accept.clone())
|
195
|
+
.await)
|
196
|
+
}
|
197
|
+
async_channel::TrySendError::Closed(err) => {
|
198
|
+
error!("Error occurred: {:?}", err);
|
199
|
+
Ok(INTERNAL_SERVER_ERROR_RESPONSE
|
200
|
+
.to_http_response(context.accept.clone())
|
201
|
+
.await)
|
202
|
+
}
|
203
|
+
},
|
199
204
|
_ => match receiver.recv().await {
|
200
205
|
Some(first_frame) => Ok(response
|
201
206
|
.build(first_frame, receiver, shutdown_channel)
|
@@ -347,7 +347,7 @@ impl ItsiHttpResponse {
|
|
347
347
|
})?;
|
348
348
|
let header_value = unsafe { HeaderValue::from_maybe_shared_unchecked(value) };
|
349
349
|
if let Some(ref mut resp) = *self.data.response.write() {
|
350
|
-
resp.headers_mut().
|
350
|
+
resp.headers_mut().append(header_name, header_value);
|
351
351
|
}
|
352
352
|
Ok(())
|
353
353
|
}
|
@@ -364,7 +364,7 @@ impl ItsiHttpResponse {
|
|
364
364
|
})?;
|
365
365
|
for value in values {
|
366
366
|
let header_value = unsafe { HeaderValue::from_maybe_shared_unchecked(value) };
|
367
|
-
headers_mut.
|
367
|
+
headers_mut.append(&header_name, header_value);
|
368
368
|
}
|
369
369
|
}
|
370
370
|
}
|
@@ -69,6 +69,7 @@ pub struct ServerParams {
|
|
69
69
|
pub pin_worker_cores: bool,
|
70
70
|
pub scheduler_class: Option<String>,
|
71
71
|
pub oob_gc_responses_threshold: Option<u64>,
|
72
|
+
pub ruby_thread_request_backlog_size: Option<usize>,
|
72
73
|
pub middleware_loader: HeapValue<Proc>,
|
73
74
|
pub middleware: OnceLock<MiddlewareSet>,
|
74
75
|
pub binds: Vec<Bind>,
|
@@ -222,6 +223,10 @@ impl ServerParams {
|
|
222
223
|
let scheduler_class: Option<String> = rb_param_hash.fetch("scheduler_class")?;
|
223
224
|
let oob_gc_responses_threshold: Option<u64> =
|
224
225
|
rb_param_hash.fetch("oob_gc_responses_threshold")?;
|
226
|
+
|
227
|
+
let ruby_thread_request_backlog_size: Option<usize> =
|
228
|
+
rb_param_hash.fetch("ruby_thread_request_backlog_size")?;
|
229
|
+
|
225
230
|
let middleware_loader: Proc = rb_param_hash.fetch("middleware_loader")?;
|
226
231
|
let log_level: Option<String> = rb_param_hash.fetch("log_level")?;
|
227
232
|
let log_target: Option<String> = rb_param_hash.fetch("log_target")?;
|
@@ -310,6 +315,7 @@ impl ServerParams {
|
|
310
315
|
scheduler_threads,
|
311
316
|
streamable_body,
|
312
317
|
scheduler_class,
|
318
|
+
ruby_thread_request_backlog_size,
|
313
319
|
oob_gc_responses_threshold,
|
314
320
|
binds,
|
315
321
|
itsi_server_token_preference,
|
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
|
18
18
|
pub struct RubyApp {
|
19
19
|
app: Arc<HeapValue<Proc>>,
|
20
20
|
request_type: RequestType,
|
21
|
+
script_name: Option<String>,
|
21
22
|
sendfile: bool,
|
22
23
|
nonblocking: bool,
|
23
24
|
base_path: Regex,
|
@@ -53,6 +54,9 @@ impl RubyApp {
|
|
53
54
|
let base_path_src = params
|
54
55
|
.funcall::<_, _, String>(Symbol::new("[]"), ("base_path",))
|
55
56
|
.unwrap_or("".to_owned());
|
57
|
+
let script_name = params
|
58
|
+
.funcall::<_, _, Option<String>>(Symbol::new("[]"), ("script_name",))
|
59
|
+
.unwrap_or(None);
|
56
60
|
let base_path = Regex::new(&base_path_src).unwrap();
|
57
61
|
|
58
62
|
let request_type: RequestType = params
|
@@ -65,6 +69,7 @@ impl RubyApp {
|
|
65
69
|
app: Arc::new(app.into()),
|
66
70
|
sendfile,
|
67
71
|
nonblocking,
|
72
|
+
script_name,
|
68
73
|
request_type,
|
69
74
|
base_path,
|
70
75
|
}))
|
@@ -82,13 +87,14 @@ impl MiddlewareLayer for RubyApp {
|
|
82
87
|
match self.request_type {
|
83
88
|
RequestType::Http => {
|
84
89
|
let uri = req.uri().path();
|
85
|
-
let script_name = self
|
86
|
-
.base_path
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
let script_name = self.script_name.clone().unwrap_or_else(|| {
|
91
|
+
self.base_path
|
92
|
+
.captures(uri)
|
93
|
+
.and_then(|caps| caps.name("base_path"))
|
94
|
+
.map(|m| m.as_str())
|
95
|
+
.unwrap_or("/")
|
96
|
+
.to_owned()
|
97
|
+
});
|
92
98
|
ItsiHttpRequest::process_request(
|
93
99
|
self.app.clone(),
|
94
100
|
req,
|
@@ -65,9 +65,12 @@ type ThreadWorkerBuildResult = Result<(
|
|
65
65
|
pub fn build_thread_workers(params: Arc<ServerParams>, pid: Pid) -> ThreadWorkerBuildResult {
|
66
66
|
let blocking_thread_count = params.threads;
|
67
67
|
let nonblocking_thread_count = params.scheduler_threads;
|
68
|
+
let ruby_thread_request_backlog_size: usize = params
|
69
|
+
.ruby_thread_request_backlog_size
|
70
|
+
.unwrap_or_else(|| (blocking_thread_count as u16 * 30) as usize);
|
68
71
|
|
69
72
|
let (blocking_sender, blocking_receiver) =
|
70
|
-
async_channel::bounded(
|
73
|
+
async_channel::bounded(ruby_thread_request_backlog_size);
|
71
74
|
let blocking_receiver_ref = Arc::new(blocking_receiver);
|
72
75
|
let blocking_sender_ref = blocking_sender;
|
73
76
|
let scheduler_class = load_scheduler_class(params.scheduler_class.clone())?;
|
@@ -101,6 +101,36 @@ end.value
|
|
101
101
|
|
102
102
|
puts results.map(&:inspect)
|
103
103
|
```
|
104
|
-
|
105
104
|
to run many blocking operations simultaneously all while occupying only a single Ruby thread!
|
105
|
+
|
106
|
+
### 3 (Optional) - Enable Scheduler Refinements
|
107
|
+
You can opt-in to a tiny set of Ruby refinements provided by the `Itsi::Scheduler` to make usage even more ergonomic.
|
108
|
+
By opting in to this refinement (using `using Itsi::Scheduler`) you gain access to the top-level #schedule(&block) method, as well
|
109
|
+
as enumerable methods #schedule_each, and #schedule_map.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
|
113
|
+
using Itsi::Scheduler
|
114
|
+
|
115
|
+
# Fire-and-forget: 100 HTTP calls in parallel
|
116
|
+
100.times.schedule_each do |i|
|
117
|
+
Net::HTTP.get(URI("https://example.com/#{i}"))
|
118
|
+
end
|
119
|
+
|
120
|
+
# Concurrent transform that keeps the original order
|
121
|
+
squares = (1..20).schedule_map { |n| n * n }
|
122
|
+
puts squares.inspect
|
123
|
+
# => [1, 4, 9, 16, … 400]
|
124
|
+
|
125
|
+
# Manual orchestration — still one thread
|
126
|
+
schedule do
|
127
|
+
a, b = Queue.new, Queue.new
|
128
|
+
|
129
|
+
schedule { a << Net::HTTP.get(URI("https://httpbin.org/get")) }
|
130
|
+
schedule { b << Net::HTTP.get(URI("https://httpbin.org/uuid")) }
|
131
|
+
|
132
|
+
puts a.pop
|
133
|
+
puts b.pop
|
134
|
+
end
|
135
|
+
```
|
106
136
|
{{% /steps %}}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Before running this test, go to the ./slow_service directory, and start the slow running service
|
4
|
+
# on port 3005, by running `itsi`.
|
5
|
+
|
6
|
+
# Single thread for blocking test.
|
7
|
+
threads 1
|
8
|
+
|
9
|
+
# Single thread for non-blocking test.
|
10
|
+
scheduler_threads 1
|
11
|
+
|
12
|
+
shutdown_timeout 1.0 # Shutdown Timeout in Seconds
|
13
|
+
|
14
|
+
# Small backlogs for test purposes
|
15
|
+
ruby_thread_request_backlog_size 100
|
16
|
+
|
17
|
+
# Enable Itsi's fiber scheduler.
|
18
|
+
fiber_scheduler true
|
19
|
+
|
20
|
+
# Send requests to http://localhost:3000/nonblocking.
|
21
|
+
# The app at config.ru runs a slow endpoint (takes 3+ seconds).
|
22
|
+
# When using this endpoint you can have a very large number of simultaneous inflight requests.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# Example benchmark:
|
26
|
+
# Non-blocking mode. 100 requests at a time, service takes 2s to respond. Throughput of ~50rps expected.
|
27
|
+
# ❯ wrk http://0.0.0.0:3000/nonblocking -c 100 -d 10
|
28
|
+
# Running 10s test @ http://0.0.0.0:3000/nonblocking
|
29
|
+
# 2 threads and 100 connections
|
30
|
+
# Thread Stats Avg Stdev Max +/- Stdev
|
31
|
+
# Latency 0.00us 0.00us 0.00us nan%
|
32
|
+
# Req/Sec 65.00 109.41 316.00 84.62%
|
33
|
+
# 500 requests in 10.10s, 69.34KB read
|
34
|
+
# Socket errors: connect 0, read 0, write 0, timeout 500
|
35
|
+
# Requests/sec: 49.50
|
36
|
+
# Transfer/sec: 6.86KB
|
37
|
+
|
38
|
+
location 'nonblocking' do
|
39
|
+
rackup_file 'config.ru', nonblocking: true, script_name: ''
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# Send requests to http://localhost:3000/blocking.
|
44
|
+
# The app at config.ru runs a slow endpoint (takes 3+ seconds).
|
45
|
+
# When using this endpoint, concurrency is limited by the number of blocking threads available.
|
46
|
+
#
|
47
|
+
# Blocking mode. Requests are executed sequentially , service takes 2s to respond. Throughput of ~0.5rps expected.
|
48
|
+
# ❯ wrk http://0.0.0.0:3000/nonblocking -c 100 -d 10
|
49
|
+
# Running 10s test @ http://0.0.0.0:3000/blocking
|
50
|
+
# 2 threads and 100 connections
|
51
|
+
# Thread Stats Avg Stdev Max +/- Stdev
|
52
|
+
# Latency 0.00us 0.00us 0.00us nan%
|
53
|
+
# Req/Sec 0.00 0.00 0.00 100.00%
|
54
|
+
# 5 requests in 10.10s, 710.00B read
|
55
|
+
# Socket errors: connect 0, read 0, write 0, timeout 5
|
56
|
+
# Requests/sec: 0.49
|
57
|
+
|
58
|
+
location 'blocking' do
|
59
|
+
rackup_file 'config.ru', script_name: ''
|
60
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
# This could be any Rack app, a Rails app, a Sinatra app, etc.
|
4
|
+
# We're going to use a simple inline rack handler for now.
|
5
|
+
|
6
|
+
run ->(_) do
|
7
|
+
result = Net::HTTP.new('127.0.0.1', 3005).get('/?sleep=2')
|
8
|
+
[result.code.to_i, {'content-type' => 'text/html'}, [result.body]]
|
9
|
+
end
|
data/gems/scheduler/Cargo.lock
CHANGED
@@ -0,0 +1,96 @@
|
|
1
|
+
module Itsi
|
2
|
+
module ScheduleRefinement
|
3
|
+
# Useful helper functions for using cooperative multi-tasking in Ruby.
|
4
|
+
# Opt-in to usage by executing `using Itsi::ScheduleRefinement` in any places
|
5
|
+
# you intend to use it.
|
6
|
+
#
|
7
|
+
# After this you can do things like the following
|
8
|
+
#
|
9
|
+
# 1. Launch batch concurrent fire-and-forget jobs.
|
10
|
+
# * 100.times.schedule_each{ sleep 0.1 }
|
11
|
+
#
|
12
|
+
# 2. Launch batch concurrent transofmrs
|
13
|
+
# See how `schedule_map` retains ordering, despite sleeping for randomized amount of time.
|
14
|
+
#
|
15
|
+
# * 100.times.schedule_map{|i| sleep Random.rand(0.0..0.05); i }
|
16
|
+
#
|
17
|
+
# 3. Manually organize fibers to run concurrently.
|
18
|
+
#
|
19
|
+
# require "net/http"
|
20
|
+
# schedule do
|
21
|
+
# req1, req2 = Queue.new, Queue.new
|
22
|
+
# schedule do
|
23
|
+
# puts "Making request 1"
|
24
|
+
# req1 << Net::HTTP.get(URI("http://httpbin.org/get"))
|
25
|
+
# puts "Finished request 1"
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# schedule do
|
29
|
+
# puts "Making request 2"
|
30
|
+
# req2 << Net::HTTP.get(URI("http://httpbin.org/get"))
|
31
|
+
# puts "Finished request 2"
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# res1, res2 = [req1, req2].map(&:pop)
|
35
|
+
# end
|
36
|
+
refine Kernel do
|
37
|
+
private def schedule(&blk) # rubocop:disable Metrics/MethodLength
|
38
|
+
return unless blk
|
39
|
+
|
40
|
+
if Fiber.scheduler.nil?
|
41
|
+
result = nil
|
42
|
+
Thread.new do
|
43
|
+
Fiber.set_scheduler Itsi::Scheduler.new
|
44
|
+
Fiber.schedule { result = blk.call }
|
45
|
+
end.join
|
46
|
+
result
|
47
|
+
else
|
48
|
+
Fiber.schedule(&blk)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
module EnumerableExtensions
|
54
|
+
using ScheduleRefinement
|
55
|
+
def schedule_each(&block)
|
56
|
+
enum = Enumerator.new do |y|
|
57
|
+
schedule do
|
58
|
+
each { |item| schedule{ y.yield(item) } }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
block_given? ? enum.each(&block) : enum.each
|
63
|
+
end
|
64
|
+
|
65
|
+
def schedule_map(&block)
|
66
|
+
return Enumerator.new do |y|
|
67
|
+
schedule do
|
68
|
+
with_index.each_with_object([]) do |(item, index), agg|
|
69
|
+
schedule do
|
70
|
+
agg[index] = (y << item)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end.map unless block_given?
|
75
|
+
schedule do
|
76
|
+
with_index.each_with_object([]) do |(item, index), agg|
|
77
|
+
schedule do
|
78
|
+
agg[index] = block[item]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
refine Enumerator do
|
87
|
+
define_method(:schedule_each, EnumerableExtensions.instance_method(:schedule_each))
|
88
|
+
define_method(:schedule_map, EnumerableExtensions.instance_method(:schedule_map))
|
89
|
+
end
|
90
|
+
|
91
|
+
refine Enumerable do
|
92
|
+
define_method(:schedule_each, EnumerableExtensions.instance_method(:schedule_each))
|
93
|
+
define_method(:schedule_map, EnumerableExtensions.instance_method(:schedule_map))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -2,37 +2,10 @@
|
|
2
2
|
|
3
3
|
require_relative "scheduler/version"
|
4
4
|
require_relative "scheduler/itsi_scheduler"
|
5
|
+
require_relative "schedule_refinement"
|
5
6
|
|
6
7
|
module Itsi
|
7
|
-
module ScheduleUtils
|
8
|
-
def schedule(&block)
|
9
|
-
return to_enum(:schedule) unless block_given?
|
10
|
-
|
11
|
-
Object.schedule do
|
12
|
-
each { |item| Object.schedule { block.call(item) } }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
8
|
class Scheduler
|
18
|
-
def self.enable_schedule_keyword!
|
19
|
-
Object.define_method(:schedule) do |&blk|
|
20
|
-
result = nil
|
21
|
-
return result unless blk
|
22
|
-
|
23
|
-
if Fiber.scheduler.nil?
|
24
|
-
Thread.new do
|
25
|
-
Fiber.set_scheduler Itsi::Scheduler.new
|
26
|
-
Fiber.schedule { result = blk[] }
|
27
|
-
end.join
|
28
|
-
else
|
29
|
-
Fiber.schedule { result = blk[] }
|
30
|
-
end
|
31
|
-
result
|
32
|
-
end
|
33
|
-
Enumerable.include(ScheduleUtils)
|
34
|
-
end
|
35
|
-
|
36
9
|
class Error < StandardError; end
|
37
10
|
|
38
11
|
def self.resume_token
|
data/gems/server/Cargo.lock
CHANGED
@@ -11,14 +11,17 @@ module Itsi
|
|
11
11
|
].flatten
|
12
12
|
|
13
13
|
listing.each do |file|
|
14
|
-
current = klass.subclasses
|
14
|
+
current = klass.subclasses.dup
|
15
15
|
require file
|
16
16
|
following = klass.subclasses
|
17
17
|
new_class = (following - current).first
|
18
18
|
|
19
19
|
documentation_file = "#{file[/(.*)\.rb/, 1]}.md"
|
20
20
|
documentation_file = "#{file[%r{(.*)/[^/]+\.rb}, 1]}/_index.md" unless File.exist?(documentation_file)
|
21
|
-
|
21
|
+
unless File.exist?(documentation_file) && new_class
|
22
|
+
new_class&.documentation "Documentation not found"
|
23
|
+
next
|
24
|
+
end
|
22
25
|
|
23
26
|
new_class.documentation IO.read(documentation_file)
|
24
27
|
.gsub(/^---.*?\n.*?-+/m, "") # Strip frontmatter
|
@@ -26,12 +26,13 @@ module Itsi
|
|
26
26
|
paths: Array(Or(Type(String), Type(Regexp))),
|
27
27
|
handler: Type(Proc) & Required(),
|
28
28
|
http_methods: Array(Type(String)),
|
29
|
+
script_name: Type(String).default(nil),
|
29
30
|
nonblocking: Bool()
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
|
-
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, &handler_proc)
|
34
|
-
location.endpoint(path, handler, http_methods: ["DELETE"], nonblocking: nonblocking, &handler_proc)
|
34
|
+
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, script_name: nil, &handler_proc) # rubocop:disable Metrics/ParameterLists,Lint/MissingSuper
|
35
|
+
location.endpoint(path, handler, http_methods: ["DELETE"], nonblocking: nonblocking, script_name: script_name, &handler_proc)
|
35
36
|
end
|
36
37
|
|
37
38
|
def build!
|
@@ -28,17 +28,24 @@ module Itsi
|
|
28
28
|
paths: Array(Or(Type(String), Type(Regexp))),
|
29
29
|
handler: Type(Proc) & Required(),
|
30
30
|
http_methods: Array(Type(String)),
|
31
|
+
script_name: Type(String).default(nil),
|
31
32
|
nonblocking: Bool()
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
35
|
-
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, &handler_proc)
|
36
|
+
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, script_name: nil, &handler_proc)
|
36
37
|
raise "Can not combine a controller method and inline handler" if handler && handler_proc
|
37
38
|
handler_proc = location.controller.method(handler).to_proc if handler.is_a?(Symbol) || handler.is_a?(String)
|
38
39
|
|
39
40
|
super(
|
40
41
|
location,
|
41
|
-
{
|
42
|
+
{
|
43
|
+
paths: Array(path),
|
44
|
+
handler: handler_proc,
|
45
|
+
http_methods: http_methods,
|
46
|
+
nonblocking: nonblocking,
|
47
|
+
script_name: script_name
|
48
|
+
}
|
42
49
|
)
|
43
50
|
|
44
51
|
num_required, keywords = Itsi::Server::TypedHandlers::SourceParser.extract_expr_from_source_location(handler_proc)
|
@@ -75,7 +82,11 @@ module Itsi
|
|
75
82
|
|
76
83
|
def build!
|
77
84
|
params = @params
|
78
|
-
app = {
|
85
|
+
app = {
|
86
|
+
preloader: -> { params[:handler] },
|
87
|
+
nonblocking: @params[:nonblocking],
|
88
|
+
script_name: @params[:script_name]
|
89
|
+
}
|
79
90
|
|
80
91
|
if @params[:paths] == [""] && @params[:http_methods].empty?
|
81
92
|
location.middleware[:app] = app
|
@@ -26,12 +26,13 @@ module Itsi
|
|
26
26
|
paths: Array(Or(Type(String), Type(Regexp))),
|
27
27
|
handler: Type(Proc) & Required(),
|
28
28
|
http_methods: Array(Type(String)),
|
29
|
+
script_name: Type(String).default(nil),
|
29
30
|
nonblocking: Bool()
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
|
-
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, &handler_proc)
|
34
|
-
location.endpoint(path, handler, http_methods: ["GET", "HEAD"], nonblocking: nonblocking, &handler_proc)
|
34
|
+
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, script_name: nil, &handler_proc) # rubocop:disable Lint/MissingSuper,Metrics/ParameterLists
|
35
|
+
location.endpoint(path, handler, http_methods: ["GET", "HEAD"], nonblocking: nonblocking, script_name: script_name, &handler_proc)
|
35
36
|
end
|
36
37
|
|
37
38
|
def build!
|
@@ -26,12 +26,13 @@ module Itsi
|
|
26
26
|
paths: Array(Or(Type(String), Type(Regexp))),
|
27
27
|
handler: Type(Proc) & Required(),
|
28
28
|
http_methods: Array(Type(String)),
|
29
|
+
script_name: Type(String).default(nil),
|
29
30
|
nonblocking: Bool()
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
|
-
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, &handler_proc)
|
34
|
-
location.endpoint(path, handler, http_methods: ["PATCH"], nonblocking: nonblocking, &handler_proc)
|
34
|
+
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, script_name: nil, &handler_proc) # rubocop:disable Lint/MissingSuper
|
35
|
+
location.endpoint(path, handler, http_methods: ["PATCH"], nonblocking: nonblocking, script_name: script_name, &handler_proc)
|
35
36
|
end
|
36
37
|
|
37
38
|
def build!
|
@@ -26,12 +26,13 @@ module Itsi
|
|
26
26
|
paths: Array(Or(Type(String), Type(Regexp))),
|
27
27
|
handler: Type(Proc) & Required(),
|
28
28
|
http_methods: Array(Type(String)),
|
29
|
+
script_name: Type(String).default(nil),
|
29
30
|
nonblocking: Bool()
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
|
-
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, &handler_proc)
|
34
|
-
location.endpoint(path, handler, http_methods: ["POST"], nonblocking: nonblocking, &handler_proc)
|
34
|
+
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, script_name: nil, &handler_proc) # rubocop:disable Lint/MissingSuper
|
35
|
+
location.endpoint(path, handler, http_methods: ["POST"], nonblocking: nonblocking, script_name: script_name, &handler_proc)
|
35
36
|
end
|
36
37
|
|
37
38
|
def build!
|
@@ -26,12 +26,13 @@ module Itsi
|
|
26
26
|
paths: Array(Or(Type(String), Type(Regexp))),
|
27
27
|
handler: Type(Proc) & Required(),
|
28
28
|
http_methods: Array(Type(String)),
|
29
|
+
script_name: Type(String).default(nil),
|
29
30
|
nonblocking: Bool()
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
|
-
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, &handler_proc)
|
34
|
-
location.endpoint(path, handler, http_methods: ["PUT"], nonblocking: nonblocking, &handler_proc)
|
34
|
+
def initialize(location, path="", handler=nil, http_methods: [], nonblocking: false, script_name: nil, &handler_proc) # rubocop:disable Lint/MissingSuper,Metrics/ParameterLists
|
35
|
+
location.endpoint(path, handler, http_methods: ["PUT"], nonblocking: nonblocking, script_name: script_name, &handler_proc)
|
35
36
|
end
|
36
37
|
|
37
38
|
def build!
|
@@ -44,6 +44,24 @@ $ curl http://0.0.0.0:3000/root/child_path
|
|
44
44
|
:/root/child_path
|
45
45
|
```
|
46
46
|
|
47
|
+
### `SCRIPT_NAME` and `PATH_INFO` Rack ENV variables.
|
48
|
+
Rack applications mounted at a subpath will, by default, receive a `SCRIPT_NAME` value that includes the subpath at which the app is mounted, and a `PATH_INFO` value that is relative to the subpath at which the rack app is mounted.
|
49
|
+
If you wish to use location blocks only to control the middleware that applies to a rack app, but still have it behave as if it were mounted elsewhere (e.g. at the root), you can explicitly set the `script_name` option.
|
50
|
+
E.g.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
location "/subpath/*" do
|
54
|
+
rackup_file "config.ru", script_name: '/'
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
```bash
|
59
|
+
# Our script-name override kicks in here, even though the app is mounted under `/subpath`
|
60
|
+
$ curl http://0.0.0.0:3000/subpath/child_path
|
61
|
+
/:/subpath/child_path
|
62
|
+
```
|
63
|
+
|
64
|
+
|
47
65
|
### Options
|
48
66
|
* `nonblocking` (default false). Determines whether requests sent to this Rack application should be run on non-blocking threads. Only applies if running in hybrid (non-blocking and blocking thread pool) mode. Otherwise this is a no-op and will run in whatever mode is set globally.
|
49
67
|
* `sendfile` (default true). Determines whether Itsi should respect the `X-Sendfile` header set by the Rack application and use the `sendfile` function to efficiently send files. (Despite the name, this does not use the OS-level `sendfile` system call). Note. Itsi enforces the restriction that the referenced file must be within a child directory of the application root.
|
@@ -15,6 +15,7 @@ module Itsi
|
|
15
15
|
schema do
|
16
16
|
{
|
17
17
|
nonblocking: Bool().default(false),
|
18
|
+
script_name: Type(String).default(nil),
|
18
19
|
sendfile: Bool().default(true)
|
19
20
|
}
|
20
21
|
end
|
@@ -31,6 +32,7 @@ module Itsi
|
|
31
32
|
preloader: -> { @app },
|
32
33
|
sendfile: @params[:sendfile],
|
33
34
|
nonblocking: @params[:nonblocking],
|
35
|
+
script_name: @params[:script_name],
|
34
36
|
base_path: "^(?<base_path>#{location.paths_from_parent.gsub(/\.\*\)$/, ")")}).*$"
|
35
37
|
}
|
36
38
|
location.middleware[:app] = app_args
|
@@ -39,7 +39,6 @@ run(Rack::Builder.app do
|
|
39
39
|
use Rack::CommonLogger
|
40
40
|
run ->(env) { [200, { 'content-type' => 'text/plain' }, [[env['SCRIPT_NAME'], env['PATH_INFO']].join(":") ] ] }
|
41
41
|
end)
|
42
|
-
|
43
42
|
```
|
44
43
|
|
45
44
|
```bash
|
@@ -50,6 +49,26 @@ $ curl http://0.0.0.0:3000/root/child_path
|
|
50
49
|
:/root/child_path
|
51
50
|
```
|
52
51
|
|
52
|
+
### `SCRIPT_NAME` and `PATH_INFO` Rack ENV variables.
|
53
|
+
Rack applications mounted at a subpath will, by default, receive a `SCRIPT_NAME` value that includes the subpath at which the app is mounted, and a `PATH_INFO` value that is relative to the subpath at which the rack app is mounted.
|
54
|
+
If you wish to use location blocks only to control the middleware that applies to a rack app, but still have it behave as if it were mounted elsewhere (e.g. at the root), you can explicitly set the `script_name` option.
|
55
|
+
E.g.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
location "/subpath/*" do
|
59
|
+
run(Rack::Builder.app do
|
60
|
+
use Rack::CommonLogger
|
61
|
+
run ->(env) { [200, { 'content-type' => 'text/plain' }, [[env['SCRIPT_NAME'], env['PATH_INFO']].join(":") ] ] }
|
62
|
+
end, script_name: '/')
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
```bash
|
67
|
+
# Our script-name override kicks in here, even though the app is mounted under `/subpath`
|
68
|
+
$ curl http://0.0.0.0:3000/subpath/child_path
|
69
|
+
/:/subpath/child_path
|
70
|
+
```
|
71
|
+
|
53
72
|
### Options
|
54
73
|
* `nonblocking` (default false). Determines whether requests sent to this Rack application should be run on non-blocking threads. Only applies if running in hybrid (non-blocking and blocking thread pool) mode. Otherwise this is a no-op and will run in whatever mode is set globally.
|
55
74
|
* `sendfile` (default true). Determines whether Itsi should respect the `X-Sendfile` header set by the Rack application and use the `sendfile` function to efficiently send files. (Despite the name, this does not use the OS-level `sendfile` system call). Note. Itsi enforces the restriction that the referenced file must be within a child directory of the application root.
|
@@ -15,6 +15,7 @@ module Itsi
|
|
15
15
|
schema do
|
16
16
|
{
|
17
17
|
nonblocking: Bool().default(false),
|
18
|
+
script_name: Type(String).default(nil),
|
18
19
|
sendfile: Bool().default(true)
|
19
20
|
}
|
20
21
|
end
|
@@ -30,6 +31,7 @@ module Itsi
|
|
30
31
|
preloader: -> { Itsi::Server::RackInterface.for(@app) },
|
31
32
|
sendfile: @params[:sendfile],
|
32
33
|
nonblocking: @params[:nonblocking],
|
34
|
+
script_name: @params[:script_name],
|
33
35
|
base_path: "^(?<base_path>#{location.paths_from_parent.gsub(/\.\*\)$/, ')')}).*$"
|
34
36
|
}
|
35
37
|
location.middleware[:app] = app_args
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
title: Ruby Thread Request Backlog Size
|
3
|
+
url: /options/ruby_thread_request_backlog_size
|
4
|
+
---
|
5
|
+
|
6
|
+
Configures the size of the backlog queue for incoming requests in the Ruby thread pool.
|
7
|
+
Up to this many requests can be queued at once before the server rejects further requests to Ruby workers (note this does not block other requests to proxied hosts or for static assets).
|
8
|
+
|
9
|
+
The default value is `30 x number of threads`.
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
```ruby {filename=Itsi.rb}
|
13
|
+
ruby_thread_request_backlog_size 20
|
14
|
+
```
|
15
|
+
|
16
|
+
```ruby {filename=Itsi.rb}
|
17
|
+
ruby_thread_request_backlog_size 100
|
18
|
+
```
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Itsi
|
2
|
+
class Server
|
3
|
+
module Config
|
4
|
+
class RubyThreadRequestBacklogSize < Option
|
5
|
+
|
6
|
+
insert_text <<~SNIPPET
|
7
|
+
ruby_thread_request_backlog_size ${1|10,25,50,100|}
|
8
|
+
SNIPPET
|
9
|
+
|
10
|
+
detail "The maximum number of requests that can be queued for processing by the Ruby thread."
|
11
|
+
|
12
|
+
schema do
|
13
|
+
(Type(Integer)).default(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -25,10 +25,17 @@ fiber_scheduler true
|
|
25
25
|
# We mount the same app *twice*.
|
26
26
|
# For a specific route prefix, all requests will be sent to non blocking threads.
|
27
27
|
# All others fall through to the default mount
|
28
|
+
|
28
29
|
location "/heavy_io/*" do
|
30
|
+
# You can optionally use the `script_name: ""` option here to set the base path for the mounted app (useful if a nested app
|
31
|
+
# should still serve requests as if it was mounted at the root).
|
32
|
+
# Otherwise it will infer the script-name based on the parent location block.
|
29
33
|
rackup_file "./config.ru", nonblocking: true
|
30
34
|
end
|
31
35
|
|
32
36
|
rackup_file "./config.ru"
|
33
37
|
|
34
38
|
```
|
39
|
+
## Examples.
|
40
|
+
|
41
|
+
See [https://github.com/wouterken/itsi/tree/main/examples/hybrid_scheduler_mode](hybrid_scheduler_mode) example in the Git repository.
|
@@ -134,6 +134,9 @@ module Itsi
|
|
134
134
|
oob_gc_responses_threshold: args.fetch(:oob_gc_responses_threshold) do
|
135
135
|
itsifile_config.fetch(:oob_gc_responses_threshold, nil)
|
136
136
|
end,
|
137
|
+
ruby_thread_request_backlog_size: args.fetch(:ruby_thread_request_backlog_size) do
|
138
|
+
itsifile_config.fetch(:ruby_thread_request_backlog_size, nil)
|
139
|
+
end,
|
137
140
|
log_level: args.fetch(:log_level) { itsifile_config.fetch(:log_level, nil) },
|
138
141
|
log_format: args.fetch(:log_format) { itsifile_config.fetch(:log_format, nil) },
|
139
142
|
log_target: args.fetch(:log_target) { itsifile_config.fetch(:log_target, nil) },
|
@@ -40,13 +40,12 @@ module Itsi
|
|
40
40
|
# 2. Set Headers
|
41
41
|
body_streamer = streaming_body?(body) ? body : headers.delete("rack.hijack")
|
42
42
|
headers.each do |key, value|
|
43
|
-
|
43
|
+
if value.is_a?(Array)
|
44
|
+
value.each do |v|
|
45
|
+
response[key] = v
|
46
|
+
end
|
47
|
+
elsif value.is_a?(String)
|
44
48
|
response[key] = value
|
45
|
-
next
|
46
|
-
end
|
47
|
-
|
48
|
-
value.each do |v|
|
49
|
-
response[key] = v
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "../helpers/test_helper"
|
2
|
+
|
3
|
+
class TestRubyThreadRequestBacklogSize < Minitest::Test
|
4
|
+
|
5
|
+
def test_ruby_thread_request_backlog_size
|
6
|
+
server(
|
7
|
+
itsi_rb: lambda do
|
8
|
+
threads 1
|
9
|
+
workers 1
|
10
|
+
ruby_thread_request_backlog_size 1
|
11
|
+
get("/foo"){|r| sleep 0.1; r.ok "ok" }
|
12
|
+
end) do
|
13
|
+
responses = 3.times.map{ Thread.new{ get_resp("/foo") } }.map(&:value)
|
14
|
+
|
15
|
+
assert_equal "ok", responses.first.body
|
16
|
+
assert_equal "200", responses.first.code
|
17
|
+
assert_equal "503", responses.last.code
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_ruby_thread_request_backlog_size_default
|
22
|
+
server(
|
23
|
+
itsi_rb: lambda do
|
24
|
+
threads 1
|
25
|
+
workers 1
|
26
|
+
# ruby_thread_request_backlog_size 1 - Disabled. Should revert to more generous default
|
27
|
+
get("/foo"){|r| sleep 0.01; r.ok "ok" }
|
28
|
+
end) do
|
29
|
+
responses = 29.times.map{ Thread.new{ get_resp("/foo") } }.map(&:value)
|
30
|
+
|
31
|
+
assert_equal "ok", responses.first.body
|
32
|
+
assert_equal "200", responses.first.code
|
33
|
+
assert_equal "ok", responses.last.body
|
34
|
+
assert_equal "200", responses.last.code
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -306,4 +306,63 @@ class TestRackServer < Minitest::Test
|
|
306
306
|
assert_equal Net::HTTP.get(URI("http://#{host}:#{port}")), "Hello, Rackup!"
|
307
307
|
Process.kill(:SIGINT, Process.pid)
|
308
308
|
end
|
309
|
+
|
310
|
+
def test_script_name_inferred_from_mount
|
311
|
+
server(itsi_rb: lambda do
|
312
|
+
location "foo*" do
|
313
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["SCRIPT_NAME"]]] }
|
314
|
+
end
|
315
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["SCRIPT_NAME"]]] }
|
316
|
+
end) do
|
317
|
+
assert_equal get("/foo/bar"), "/foo"
|
318
|
+
assert_equal get("/baz"), ""
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_path_info_inferred_from_mount
|
323
|
+
server(itsi_rb: lambda do
|
324
|
+
location "foo*" do
|
325
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["PATH_INFO"]]] }
|
326
|
+
end
|
327
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["PATH_INFO"]]] }
|
328
|
+
end) do
|
329
|
+
assert_equal get("/foo/bar"), "/bar"
|
330
|
+
assert_equal get("/baz"), "/baz"
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
def test_script_name_explicitly_set
|
335
|
+
server(itsi_rb: lambda do
|
336
|
+
location "foo*" do
|
337
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["SCRIPT_NAME"]]] }, script_name: "/overridden"
|
338
|
+
end
|
339
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["SCRIPT_NAME"]]] }, script_name: ""
|
340
|
+
end) do
|
341
|
+
assert_equal get("/foo/bar"), "/overridden"
|
342
|
+
assert_equal get("/baz"), ""
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_path_info_when_script_name_explicitly_set
|
347
|
+
server(itsi_rb: lambda do
|
348
|
+
location "foo*" do
|
349
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["PATH_INFO"]]] }, script_name: ""
|
350
|
+
end
|
351
|
+
run ->(env) { [200, { "content-type" => "text/plain" }, [env["PATH_INFO"]]] }, script_name: ""
|
352
|
+
end) do
|
353
|
+
assert_equal get("/foo/bar"), "/foo/bar"
|
354
|
+
assert_equal get("/baz"), "/baz"
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_multi_field_headers
|
359
|
+
server(app_with_lint: lambda do |env|
|
360
|
+
[200, { "content-type" => "text/plain", "x-example" => ["one, two, three", "four, five"] }, ["Multiple Field Headers"]]
|
361
|
+
end) do
|
362
|
+
response = get_resp("/")
|
363
|
+
assert_equal "200", response.code
|
364
|
+
assert_equal "one, two, three, four, five", response["x-example"]
|
365
|
+
assert_equal "Multiple Field Headers", response.body
|
366
|
+
end
|
367
|
+
end
|
309
368
|
end
|
data/lib/itsi/version.rb
CHANGED
data/tasks.txt
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itsi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wouter Coppieters
|
@@ -253,6 +253,9 @@ files:
|
|
253
253
|
- examples/file_server/itsi-server-100.png
|
254
254
|
- examples/file_server/subdirectory/movies.csv
|
255
255
|
- examples/helpers/datastore.rb
|
256
|
+
- examples/hybrid_scheduler_mode/Itsi.rb
|
257
|
+
- examples/hybrid_scheduler_mode/config.ru
|
258
|
+
- examples/hybrid_scheduler_mode/slow_service/Itsi.rb
|
256
259
|
- examples/media_server/Itsi.rb
|
257
260
|
- examples/media_server/README.md
|
258
261
|
- examples/media_server/images/itsi-server-100.png
|
@@ -677,9 +680,9 @@ files:
|
|
677
680
|
- gems/scheduler/bin/setup
|
678
681
|
- gems/scheduler/itsi-scheduler-100.png
|
679
682
|
- gems/scheduler/itsi-scheduler.gemspec
|
683
|
+
- gems/scheduler/lib/itsi/schedule_refinement.rb
|
680
684
|
- gems/scheduler/lib/itsi/scheduler.rb
|
681
685
|
- gems/scheduler/lib/itsi/scheduler/version.rb
|
682
|
-
- gems/scheduler/sig/itsi_scheduler.rbs
|
683
686
|
- gems/scheduler/test/helpers/test_helper.rb
|
684
687
|
- gems/scheduler/test/test_active_record.rb
|
685
688
|
- gems/scheduler/test/test_address_resolve.rb
|
@@ -941,6 +944,8 @@ files:
|
|
941
944
|
- gems/server/lib/itsi/server/config/options/reuse_address.rb
|
942
945
|
- gems/server/lib/itsi/server/config/options/reuse_port.md
|
943
946
|
- gems/server/lib/itsi/server/config/options/reuse_port.rb
|
947
|
+
- gems/server/lib/itsi/server/config/options/ruby_thread_request_backlog_size.md
|
948
|
+
- gems/server/lib/itsi/server/config/options/ruby_thread_request_backlog_size.rb
|
944
949
|
- gems/server/lib/itsi/server/config/options/scheduler_threads.md
|
945
950
|
- gems/server/lib/itsi/server/config/options/scheduler_threads.rb
|
946
951
|
- gems/server/lib/itsi/server/config/options/shutdown_timeout.md
|
@@ -976,7 +981,6 @@ files:
|
|
976
981
|
- gems/server/lib/itsi/standard_headers.rb
|
977
982
|
- gems/server/lib/ruby_lsp/itsi/addon.rb
|
978
983
|
- gems/server/lib/shell_completions/completions.rb
|
979
|
-
- gems/server/sig/itsi_server.rbs
|
980
984
|
- gems/server/test/helpers/test_helper.rb
|
981
985
|
- gems/server/test/middleware/allow_list.rb
|
982
986
|
- gems/server/test/middleware/auth_api_key.rb
|
@@ -1010,6 +1014,7 @@ files:
|
|
1010
1014
|
- gems/server/test/middleware/test_log_requests.rb
|
1011
1015
|
- gems/server/test/options/bind.rb
|
1012
1016
|
- gems/server/test/options/header_read_timeout.rb
|
1017
|
+
- gems/server/test/options/ruby_thread_request_backlog_size.rb
|
1013
1018
|
- gems/server/test/options/test_request_timeout.rb
|
1014
1019
|
- gems/server/test/options/test_threads.rb
|
1015
1020
|
- gems/server/test/options/test_workers.rb
|