trusted 0.3.2 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe22de0a36b2b3bc06d99ce763da9541fa65adc8
4
- data.tar.gz: 2014461c82af74382935959786d7fb059de8a82c
3
+ metadata.gz: 2c8dfba7fc9d8141dfdfb8068d0824277ba0ec42
4
+ data.tar.gz: 4a7d0f63c106ff8c268ba8f7e027e6211c797c03
5
5
  SHA512:
6
- metadata.gz: 8b5217afe22e37f29b4967f3a0a42309fc57a22b53171a054fb3afaf2eb2fd18afd65542f7f34a38202f30af4d068af5d9078d3e050c741bb0e5f994716a2cbb
7
- data.tar.gz: 9b7b02314578c6be323863b20b7841501e9a89638fccf8c24a2b2d04d1331a8a27d6ff57101bf7f813f2bf43e496e81522ee514a9d9e821ae5aec06a5beea855
6
+ metadata.gz: 8bde46c7b2bed5dbb0510d45666767ee8383f1b78f397ce9bef60b23810af665c4c9b51d49e37b0b534e30173d76222232c78864c0b1281be1927f9a3d3d4c2a
7
+ data.tar.gz: ab853613b7c5c39965cfa486e734ff433939ef0c44fcaf0508402164a63cac8286322e55604d8ec7d5a3b92b5a4ade9ec03b05a9471a87574b3c8b24385d8fee
data/Rakefile CHANGED
@@ -1,8 +1,5 @@
1
1
  require 'thermite/tasks'
2
- # require 'bundler/gem_tasks'
3
- # require 'rspec/core/rake_task'
4
2
 
5
- # RSpec::Core::RakeTask.new(:spec)
6
3
  Thermite::Tasks.new(cargo_project_path: 'ext/trusted')
7
4
 
8
5
  task default: %w(thermite:build)
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "trusted"
3
- version = "0.3.2"
3
+ version = "0.4.0"
4
4
  authors = ["Dmitry Gritsay <dmitry@vinted.com>"]
5
5
 
6
6
  [lib]
@@ -7,15 +7,21 @@ use super::BindingType;
7
7
  pub struct Config {
8
8
  binding_type: BindingType,
9
9
  listen_on: String,
10
- thread_pool_size: usize,
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, listen_on: String, thread_pool_size: usize) -> Self {
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
- thread_pool_size: thread_pool_size,
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 thread_pool_size(&self) -> usize {
34
- self.thread_pool_size
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 thread_pool_size =
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("thread_pool_size", vec![])
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, thread_pool_size)
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, VM};
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.thread_pool_size());
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 thread_pool_size = self.config.thread_pool_size();
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(self.config.listen_on()).unwrap()
50
+ UnixSocketServer::new(address).unwrap()
49
51
  .handle_threads(handler, thread_pool_size).unwrap();
50
52
  },
51
53
  BindingType::Tcp => {
52
- HyperServer::http(self.config.listen_on()).unwrap()
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
- VM::thread_call_without_gvl(
64
+ Thread::call_without_gvl(
63
65
  handler_function,
64
66
  Some(unblock_function)
65
67
  );
@@ -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
- thread_pool_size: 1,
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 thread_pool_size(size)
29
- config[:thread_pool_size] = size
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, :thread_pool_size
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
- @thread_pool_size = configuration[:thread_pool_size]
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
@@ -1,3 +1,3 @@
1
1
  module Trusted
2
- VERSION = '0.3.2'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -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{Write a short summary, because Rubygems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
14
- spec.homepage = "http://this-week-in-ruru.org/"
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.3.2
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: Write a longer description or delete this line.
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: http://this-week-in-ruru.org/
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: Write a short summary, because Rubygems requires one.
202
+ summary: Rack-compatible application server
203
203
  test_files: []