plum 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -0
- data/examples/rack-example-config.rb +1 -1
- data/lib/plum/rack/cli.rb +1 -6
- data/lib/plum/rack/config.rb +1 -2
- data/lib/plum/rack/dsl.rb +0 -4
- data/lib/plum/rack/legacy_session.rb +1 -1
- data/lib/plum/rack/listener.rb +4 -4
- data/lib/plum/rack/server.rb +2 -2
- data/lib/plum/rack/session.rb +2 -0
- data/lib/plum/rack/thread_pool.rb +1 -1
- data/lib/plum/stream.rb +3 -3
- data/lib/plum/version.rb +1 -1
- data/lib/rack/handler/plum.rb +7 -4
- data/test/plum/stream/test_handle_frame.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef27822edb349c4af6092ad5e6fcfa7a197c4300
|
4
|
+
data.tar.gz: a958711115e3c29dbe9f084a831d8167005c873e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58378f43aee9a6c53e4b87d1e8f4b3a0969f79e10981eaf51af23327108d037e3d5dde0e56a090f04d749fae687262cdd45bb50f59e5201f90844568addc55c8
|
7
|
+
data.tar.gz: 1450a4e93f8a8929740c3cbd9edd5018294312cf55f87f928d0d0dbbe4c9596dca220e7c8f3a9d38113837c5d09c4d8b94c5b79ae17a607644eb3228a5913c03
|
data/.codeclimate.yml
ADDED
@@ -1,7 +1,7 @@
|
|
1
1
|
log "logs/plum.log"
|
2
2
|
debug false
|
3
3
|
server_push true
|
4
|
-
|
4
|
+
threadpool_size 20 # use 20 threads to process requests (default: 1( = disable))
|
5
5
|
fallback_legacy "127.0.0.1:8080" # forward if client doesn't support HTTP/2
|
6
6
|
|
7
7
|
user "nobody"
|
data/lib/plum/rack/cli.rb
CHANGED
@@ -44,7 +44,6 @@ module Plum
|
|
44
44
|
ENV["RACK_ENV"] = @options[:env] if @options[:env]
|
45
45
|
config[:debug] = @options[:debug] unless @options[:debug].nil?
|
46
46
|
config[:server_push] = @options[:server_push] unless @options[:server_push].nil?
|
47
|
-
config[:threaded] = @options[:threaded] unless @options[:threaded].nil?
|
48
47
|
config[:threadpool_size] = @options[:threadpool_size] unless @options[:threadpool_size].nil?
|
49
48
|
|
50
49
|
if @options[:fallback_legacy]
|
@@ -121,11 +120,7 @@ module Plum
|
|
121
120
|
@options[:key] = arg
|
122
121
|
end
|
123
122
|
|
124
|
-
o.on "--
|
125
|
-
@options[:threaded] = true
|
126
|
-
end
|
127
|
-
|
128
|
-
o.on "--threadpool-size SIZE", "Set the size of thread pool" do |arg|
|
123
|
+
o.on "--threadpool-size SIZE", "Set the size of thread pool. Set 1 to disable" do |arg|
|
129
124
|
@options[:threadpool_size] = arg.to_i
|
130
125
|
end
|
131
126
|
|
data/lib/plum/rack/config.rb
CHANGED
data/lib/plum/rack/dsl.rb
CHANGED
@@ -13,7 +13,7 @@ module Plum
|
|
13
13
|
|
14
14
|
def run
|
15
15
|
if @config[:fallback_legacy_host]
|
16
|
-
@logger.info "legacy HTTP: fallbacking to: #{@config[:fallback_legacy_host]}:#{@config[:fallback_legacy_port]}"
|
16
|
+
@svc.logger.info "legacy HTTP: fallbacking to: #{@config[:fallback_legacy_host]}:#{@config[:fallback_legacy_port]}"
|
17
17
|
upstream = TCPSocket.open(@config[:fallback_legacy_host], @config[:fallback_legacy_port])
|
18
18
|
upstream.write(@e.buf) if @e.buf
|
19
19
|
loop do
|
data/lib/plum/rack/listener.rb
CHANGED
@@ -35,11 +35,11 @@ module Plum
|
|
35
35
|
plum = ::Plum::HTTPServerConnection.new(sock.method(:write))
|
36
36
|
sess = Session.new(svc, sock, plum)
|
37
37
|
sess.run
|
38
|
-
rescue Errno::ECONNRESET, EOFError # closed
|
39
38
|
rescue ::Plum::LegacyHTTPError => e
|
40
|
-
|
39
|
+
svc.logger.info "legacy HTTP client: #{e}"
|
41
40
|
sess = LegacySession.new(svc, e, sock)
|
42
41
|
sess.run
|
42
|
+
rescue Errno::ECONNRESET, EOFError # closed
|
43
43
|
rescue => e
|
44
44
|
svc.log_exception(e)
|
45
45
|
ensure
|
@@ -97,11 +97,11 @@ module Plum
|
|
97
97
|
plum = ::Plum::ServerConnection.new(sock.method(:write))
|
98
98
|
sess = Session.new(svc, sock, plum)
|
99
99
|
sess.run
|
100
|
-
rescue Errno::ECONNRESET, EOFError # closed
|
101
100
|
rescue ::Plum::LegacyHTTPError => e
|
102
|
-
|
101
|
+
svc.logger.info "legacy HTTP client: #{e}"
|
103
102
|
sess = LegacySession.new(svc, e, sock)
|
104
103
|
sess.run
|
104
|
+
rescue Errno::ECONNRESET, EOFError # closed
|
105
105
|
rescue => e
|
106
106
|
svc.log_exception(e)
|
107
107
|
ensure
|
data/lib/plum/rack/server.rb
CHANGED
@@ -10,7 +10,7 @@ module Plum
|
|
10
10
|
@app = config[:debug] ? ::Rack::CommonLogger.new(app) : app
|
11
11
|
@logger = Logger.new(config[:log] || $stdout).tap { |l| l.level = config[:debug] ? Logger::DEBUG : Logger::INFO }
|
12
12
|
@listeners = config[:listeners].map { |lc| lc[:listener].new(lc) }
|
13
|
-
@threadpool = ThreadPool.new(@config[:threadpool_size]) if @config[:
|
13
|
+
@threadpool = ThreadPool.new(@config[:threadpool_size]) if @config[:threadpool_size] > 1
|
14
14
|
|
15
15
|
@logger.info("Plum #{::Plum::VERSION}")
|
16
16
|
@logger.info("Config: #{config}")
|
@@ -51,11 +51,11 @@ module Plum
|
|
51
51
|
# TODO: gracefully shutdown connections (wait threadpool?)
|
52
52
|
end
|
53
53
|
|
54
|
-
private
|
55
54
|
def log_exception(e)
|
56
55
|
@logger.error("#{e.class}: #{e.message}\n#{e.backtrace.map { |b| "\t#{b}" }.join("\n")}")
|
57
56
|
end
|
58
57
|
|
58
|
+
private
|
59
59
|
def drop_privileges
|
60
60
|
begin
|
61
61
|
user = @config[:user]
|
data/lib/plum/rack/session.rb
CHANGED
data/lib/plum/stream.rb
CHANGED
@@ -221,11 +221,11 @@ module Plum
|
|
221
221
|
|
222
222
|
def receive_priority_payload(payload)
|
223
223
|
esd = payload.uint32
|
224
|
-
e = esd >> 31
|
225
|
-
dependency_id =
|
224
|
+
e = (esd >> 31) == 1
|
225
|
+
dependency_id = esd & ~(1 << 31)
|
226
226
|
weight = payload.uint8(4)
|
227
227
|
|
228
|
-
update_dependency(weight: weight, parent: @connection.streams[dependency_id], exclusive: e
|
228
|
+
update_dependency(weight: weight, parent: @connection.streams[dependency_id], exclusive: e)
|
229
229
|
end
|
230
230
|
|
231
231
|
def receive_rst_stream(frame)
|
data/lib/plum/version.rb
CHANGED
data/lib/rack/handler/plum.rb
CHANGED
@@ -15,7 +15,8 @@ module Rack
|
|
15
15
|
port: opts[:Port].to_i
|
16
16
|
}
|
17
17
|
],
|
18
|
-
debug: !!opts[:Debug]
|
18
|
+
debug: !!opts[:Debug],
|
19
|
+
threadpool_size: opts[:Threads].to_i
|
19
20
|
)
|
20
21
|
|
21
22
|
@server = ::Plum::Rack::Server.new(app, config)
|
@@ -29,9 +30,10 @@ module Rack
|
|
29
30
|
|
30
31
|
def self.valid_options
|
31
32
|
{
|
32
|
-
"Host=HOST"
|
33
|
-
"Port=PORT"
|
34
|
-
"Debug"
|
33
|
+
"Host=HOST" => "Hostname to listen on (default: #{default_options[:Host]})",
|
34
|
+
"Port=PORT" => "Port to listen on (default: #{default_options[:Port]})",
|
35
|
+
"Debug" => "Turn on debug mode (default: #{default_options[:Debug]})",
|
36
|
+
"Threads=N" => "Use N threads (default: #{default_options[:Threads]})",
|
35
37
|
}
|
36
38
|
end
|
37
39
|
|
@@ -43,6 +45,7 @@ module Rack
|
|
43
45
|
Host: dev ? "localhost" : "0.0.0.0",
|
44
46
|
Port: 8080,
|
45
47
|
Debug: dev,
|
48
|
+
Threads: 20,
|
46
49
|
}
|
47
50
|
end
|
48
51
|
end
|
@@ -192,7 +192,7 @@ class StreamHandleFrameTest < Minitest::Test
|
|
192
192
|
def test_stream_handle_priority_self_depend
|
193
193
|
open_server_connection {|con|
|
194
194
|
stream = open_new_stream(con)
|
195
|
-
payload = "".push_uint32((
|
195
|
+
payload = "".push_uint32((0 << 31) | stream.id).push_uint8(6)
|
196
196
|
stream.receive_frame(Frame.new(type: :priority,
|
197
197
|
stream_id: stream.id,
|
198
198
|
payload: payload))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rhenium
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -158,6 +158,7 @@ executables:
|
|
158
158
|
extensions: []
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
|
+
- ".codeclimate.yml"
|
161
162
|
- ".gitignore"
|
162
163
|
- ".travis.yml"
|
163
164
|
- Gemfile
|