trusted 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -3
- data/ext/trusted/Cargo.toml +1 -1
- data/ext/trusted/src/config/config.rs +26 -8
- data/ext/trusted/src/core/server.rs +8 -6
- data/lib/rack/handler/trusted.rb +0 -2
- data/lib/trusted/config/builder.rb +8 -3
- data/lib/trusted/config/config.rb +3 -2
- data/lib/trusted/version.rb +1 -1
- data/trusted.gemspec +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c8dfba7fc9d8141dfdfb8068d0824277ba0ec42
|
4
|
+
data.tar.gz: 4a7d0f63c106ff8c268ba8f7e027e6211c797c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bde46c7b2bed5dbb0510d45666767ee8383f1b78f397ce9bef60b23810af665c4c9b51d49e37b0b534e30173d76222232c78864c0b1281be1927f9a3d3d4c2a
|
7
|
+
data.tar.gz: ab853613b7c5c39965cfa486e734ff433939ef0c44fcaf0508402164a63cac8286322e55604d8ec7d5a3b92b5a4ade9ec03b05a9471a87574b3c8b24385d8fee
|
data/Rakefile
CHANGED
data/ext/trusted/Cargo.toml
CHANGED
@@ -7,15 +7,21 @@ use super::BindingType;
|
|
7
7
|
pub struct Config {
|
8
8
|
binding_type: BindingType,
|
9
9
|
listen_on: String,
|
10
|
-
|
10
|
+
native_thread_pool_size: usize,
|
11
|
+
rack_thread_pool_size: usize,
|
11
12
|
}
|
12
13
|
|
13
14
|
impl Config {
|
14
|
-
pub fn new(binding_type: BindingType,
|
15
|
+
pub fn new(binding_type: BindingType,
|
16
|
+
listen_on: String,
|
17
|
+
native_thread_pool_size: usize,
|
18
|
+
rack_thread_pool_size: usize) -> Self {
|
19
|
+
|
15
20
|
Config {
|
16
21
|
binding_type: binding_type,
|
17
22
|
listen_on: listen_on,
|
18
|
-
|
23
|
+
native_thread_pool_size: native_thread_pool_size,
|
24
|
+
rack_thread_pool_size: rack_thread_pool_size,
|
19
25
|
}
|
20
26
|
}
|
21
27
|
|
@@ -30,8 +36,13 @@ impl Config {
|
|
30
36
|
}
|
31
37
|
|
32
38
|
#[inline]
|
33
|
-
pub fn
|
34
|
-
self.
|
39
|
+
pub fn native_thread_pool_size(&self) -> usize {
|
40
|
+
self.native_thread_pool_size
|
41
|
+
}
|
42
|
+
|
43
|
+
#[inline]
|
44
|
+
pub fn rack_thread_pool_size(&self) -> usize {
|
45
|
+
self.rack_thread_pool_size
|
35
46
|
}
|
36
47
|
}
|
37
48
|
|
@@ -55,12 +66,19 @@ impl From<RubyConfig> for Config {
|
|
55
66
|
let binding_type = BindingType::from(binding_type.as_str());
|
56
67
|
|
57
68
|
// TODO: raise an exception if it is not a Symbol
|
58
|
-
let
|
69
|
+
let native_thread_pool_size =
|
70
|
+
ruby_config
|
71
|
+
.send("native_thread_pool_size", vec![])
|
72
|
+
.try_convert_to::<Fixnum>().unwrap()
|
73
|
+
.to_i64() as usize;
|
74
|
+
|
75
|
+
// TODO: raise an exception if it is not a Symbol
|
76
|
+
let rack_thread_pool_size =
|
59
77
|
ruby_config
|
60
|
-
.send("
|
78
|
+
.send("rack_thread_pool_size", vec![])
|
61
79
|
.try_convert_to::<Fixnum>().unwrap()
|
62
80
|
.to_i64() as usize;
|
63
81
|
|
64
|
-
Config::new(binding_type, listen_on,
|
82
|
+
Config::new(binding_type, listen_on, native_thread_pool_size, rack_thread_pool_size)
|
65
83
|
}
|
66
84
|
}
|
@@ -4,7 +4,7 @@ use std::thread;
|
|
4
4
|
|
5
5
|
use hyper::server::Server as HyperServer;
|
6
6
|
use hyperlocal::UnixSocketServer;
|
7
|
-
use ruru::{Proc,
|
7
|
+
use ruru::{Proc, Thread};
|
8
8
|
|
9
9
|
use config::{BindingType, Config};
|
10
10
|
use core::{Core, Handler, ResponseFuture};
|
@@ -33,23 +33,25 @@ impl Server {
|
|
33
33
|
request_receiver,
|
34
34
|
ruby_handler,
|
35
35
|
core_stream,
|
36
|
-
self.config.
|
36
|
+
self.config.rack_thread_pool_size());
|
37
37
|
|
38
38
|
thread::spawn(move || {
|
39
39
|
let handler_function = || -> () {
|
40
40
|
println!("[hyper] GVL released for server thread");
|
41
41
|
|
42
|
-
let
|
42
|
+
let address = self.config.listen_on();
|
43
|
+
let thread_pool_size = self.config.native_thread_pool_size();
|
43
44
|
|
44
45
|
println!("[hyper] Spawning {} native thread(s)", thread_pool_size);
|
46
|
+
println!("[hyper] Listening on {}", address);
|
45
47
|
|
46
48
|
match *self.config.binding_type() {
|
47
49
|
BindingType::Unix => {
|
48
|
-
UnixSocketServer::new(
|
50
|
+
UnixSocketServer::new(address).unwrap()
|
49
51
|
.handle_threads(handler, thread_pool_size).unwrap();
|
50
52
|
},
|
51
53
|
BindingType::Tcp => {
|
52
|
-
HyperServer::http(
|
54
|
+
HyperServer::http(address).unwrap()
|
53
55
|
.handle_threads(handler, thread_pool_size).unwrap();
|
54
56
|
}
|
55
57
|
};
|
@@ -59,7 +61,7 @@ impl Server {
|
|
59
61
|
()
|
60
62
|
};
|
61
63
|
|
62
|
-
|
64
|
+
Thread::call_without_gvl(
|
63
65
|
handler_function,
|
64
66
|
Some(unblock_function)
|
65
67
|
);
|
data/lib/rack/handler/trusted.rb
CHANGED
@@ -10,8 +10,6 @@ module Rack
|
|
10
10
|
|
11
11
|
::Trusted::Server.new(config).listen do |request, response|
|
12
12
|
puts "REQUEST: [#{request.method}] #{request.uri}"
|
13
|
-
puts "PATH_INFO: #{request.path_info}"
|
14
|
-
puts "REQUEST HEADERS: #{request.headers.inspect}"
|
15
13
|
|
16
14
|
rack_input = StringIO::new(request.body)
|
17
15
|
|
@@ -6,7 +6,8 @@ module Trusted
|
|
6
6
|
DEFAULT_CONFIG = {
|
7
7
|
binding_type: :tcp,
|
8
8
|
listen_on: 'localhost:3000',
|
9
|
-
|
9
|
+
rack_thread_pool_size: 1,
|
10
|
+
native_thread_pool_size: 1,
|
10
11
|
}.freeze
|
11
12
|
|
12
13
|
def self.dsl(&block)
|
@@ -25,8 +26,12 @@ module Trusted
|
|
25
26
|
config[:listen_on] = address
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
-
config[:
|
29
|
+
def rack_thread_pool_size(size)
|
30
|
+
config[:rack_thread_pool_size] = size
|
31
|
+
end
|
32
|
+
|
33
|
+
def native_thread_pool_size(size)
|
34
|
+
config[:native_thread_pool_size] = size
|
30
35
|
end
|
31
36
|
|
32
37
|
def build
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module Trusted
|
2
2
|
module Config
|
3
3
|
class Config
|
4
|
-
attr_reader :binding_type, :listen_on, :
|
4
|
+
attr_reader :binding_type, :listen_on, :rack_thread_pool_size, :native_thread_pool_size
|
5
5
|
|
6
6
|
def initialize(configuration)
|
7
7
|
@binding_type = configuration[:binding_type]
|
8
8
|
@listen_on = configuration[:listen_on]
|
9
|
-
@
|
9
|
+
@rack_thread_pool_size = configuration[:rack_thread_pool_size]
|
10
|
+
@native_thread_pool_size = configuration[:native_thread_pool_size]
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
data/lib/trusted/version.rb
CHANGED
data/trusted.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Dmitry Gritsay']
|
10
10
|
spec.email = ['unseductable@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
14
|
-
spec.homepage =
|
12
|
+
spec.summary = %q{Rack-compatible application server}
|
13
|
+
spec.description = %q{Application server for Rack apps built with Rust}
|
14
|
+
spec.homepage = 'https://github.com/d-unseductable/trusted'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.extensions << 'Rakefile'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trusted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Gritsay
|
@@ -128,7 +128,7 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '1.2'
|
131
|
-
description:
|
131
|
+
description: Application server for Rack apps built with Rust
|
132
132
|
email:
|
133
133
|
- unseductable@gmail.com
|
134
134
|
executables:
|
@@ -176,7 +176,7 @@ files:
|
|
176
176
|
- lib/trusted/request/processing_pool.rb
|
177
177
|
- lib/trusted/version.rb
|
178
178
|
- trusted.gemspec
|
179
|
-
homepage:
|
179
|
+
homepage: https://github.com/d-unseductable/trusted
|
180
180
|
licenses:
|
181
181
|
- MIT
|
182
182
|
metadata: {}
|
@@ -199,5 +199,5 @@ rubyforge_project:
|
|
199
199
|
rubygems_version: 2.5.1
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
|
-
summary:
|
202
|
+
summary: Rack-compatible application server
|
203
203
|
test_files: []
|