falcon 0.19.6 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/Gemfile +3 -3
- data/examples/redis/Gemfile +8 -0
- data/examples/redis/config.ru +27 -0
- data/falcon.gemspec +5 -4
- data/lib/falcon/adapters/response.rb +5 -2
- data/lib/falcon/command.rb +1 -0
- data/lib/falcon/command/serve.rb +21 -5
- data/lib/falcon/verbose.rb +1 -1
- data/lib/falcon/version.rb +1 -1
- data/tasks/benchmark.rake +2 -2
- metadata +27 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b2de4bddd24124f6859b6fe9abf37624537b3d9175cab2d3925a897cab1ca30
|
4
|
+
data.tar.gz: ca3ca0154ec2abf520c3b2a6c0f231bc66833689236a9144ce7832e390b9a894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aee2014818ce576facb26f073df66c15cfc866f4aa9993185d98f0ebc774547fcb043a9de72f36cbaa8c977a3cdcd6af998b4860a9ad63d3cd41676ed8a5e5aa
|
7
|
+
data.tar.gz: 15a9f6d3e42d5333f533b3e005d0bf6c6fcbe533814221f8ee02b47e2152b58e91da948d607ad63d45225acc76736824baf743029b44435fe315dd872c882e07
|
data/.travis.yml
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: required
|
3
2
|
dist: xenial
|
4
3
|
cache: bundler
|
5
4
|
|
@@ -18,11 +17,14 @@ matrix:
|
|
18
17
|
- rvm: 2.4
|
19
18
|
- rvm: 2.5
|
20
19
|
- rvm: 2.6
|
20
|
+
- rvm: truffleruby
|
21
21
|
- rvm: jruby-head
|
22
22
|
env: JRUBY_OPTS="--debug -X+O"
|
23
23
|
- rvm: ruby-head
|
24
24
|
- rvm: rbx-3
|
25
25
|
allow_failures:
|
26
|
+
- rvm: truffleruby
|
26
27
|
- rvm: ruby-head
|
27
28
|
- rvm: jruby-head
|
29
|
+
- rvm: truffleruby
|
28
30
|
- rvm: rbx-3
|
data/Gemfile
CHANGED
@@ -7,10 +7,10 @@ group :development do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem '
|
11
|
-
gem '
|
10
|
+
gem 'pry'
|
11
|
+
gem 'covered', require: 'covered/rspec' if RUBY_VERSION >= "2.6.0"
|
12
12
|
|
13
|
-
gem 'async-process', '~> 1.1
|
13
|
+
gem 'async-process', '~> 1.1'
|
14
14
|
|
15
15
|
gem 'puma'
|
16
16
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'async/redis'
|
4
|
+
require 'async/clock'
|
5
|
+
|
6
|
+
CLIENT = Async::Redis::Client.new(Async::Redis.local_endpoint)
|
7
|
+
|
8
|
+
class MyApp < Sinatra::Base
|
9
|
+
get "/" do
|
10
|
+
puts "Starting BLPOP SLEEP..."
|
11
|
+
duration = Async::Clock.measure do
|
12
|
+
CLIENT.call "BLPOP", "SLEEP", 1
|
13
|
+
end
|
14
|
+
puts "Finished BLPOP SLEEP after #{duration.round(2)}s"
|
15
|
+
|
16
|
+
"ok"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
use MyApp # Then, it will get to Sinatra.
|
21
|
+
run lambda {|env| [404, {}, []]} # Bottom of the stack, give 404.
|
22
|
+
|
23
|
+
# Start server like this:
|
24
|
+
# falcon --verbose serve --threaded --concurrency 1 --bind http://localhost:9292
|
25
|
+
|
26
|
+
# Test server, e.g.:
|
27
|
+
# time ab -n 64 -c 64 http://localhost:9292/
|
data/falcon.gemspec
CHANGED
@@ -17,10 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_dependency("http-protocol", "~> 0.10.0")
|
20
|
-
|
21
|
-
spec.add_dependency("async
|
20
|
+
|
21
|
+
spec.add_dependency("async", "~> 1.13")
|
22
|
+
spec.add_dependency("async-io", "~> 1.18")
|
22
23
|
spec.add_dependency("async-http", "~> 0.37.2")
|
23
|
-
spec.add_dependency("async-container", "~> 0.
|
24
|
+
spec.add_dependency("async-container", "~> 0.9.0")
|
24
25
|
|
25
26
|
spec.add_dependency("rack", ">= 1.0")
|
26
27
|
|
@@ -30,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
30
31
|
spec.add_development_dependency "async-rspec", "~> 1.7"
|
31
32
|
spec.add_development_dependency "async-websocket", "~> 0.6.0"
|
32
33
|
|
33
|
-
spec.add_development_dependency "bundler"
|
34
|
+
spec.add_development_dependency "bundler"
|
34
35
|
spec.add_development_dependency "rspec", "~> 3.6"
|
35
36
|
spec.add_development_dependency "rake"
|
36
37
|
end
|
@@ -47,8 +47,11 @@ module Falcon
|
|
47
47
|
def self.wrap(status, headers, body)
|
48
48
|
headers = wrap_headers(headers)
|
49
49
|
|
50
|
-
|
51
|
-
headers.add('
|
50
|
+
# https://tools.ietf.org/html/rfc7231#section-7.4.2
|
51
|
+
# headers.add('server', "falcon/#{Falcon::VERSION}")
|
52
|
+
|
53
|
+
# https://tools.ietf.org/html/rfc7231#section-7.1.1.2
|
54
|
+
# headers.add('date', Time.now.httpdate)
|
52
55
|
|
53
56
|
body = Output.wrap(status, headers, body)
|
54
57
|
|
data/lib/falcon/command.rb
CHANGED
data/lib/falcon/command/serve.rb
CHANGED
@@ -42,6 +42,7 @@ module Falcon
|
|
42
42
|
|
43
43
|
option '-p/--port <number>', "Override the specified port", type: Integer
|
44
44
|
option '-h/--hostname <hostname>', "Specify the hostname which would be used for certificates, etc."
|
45
|
+
option '-t/--timeout <duration>', "Specify the maximum time to wait for blocking operations.", type: Float, default: 60
|
45
46
|
|
46
47
|
option '-c/--config <path>', "Rackup configuration file to load", default: 'config.ru'
|
47
48
|
option '-n/--concurrency <count>', "Number of processes to start", default: Async::Container.hardware_concurrency, type: Integer
|
@@ -78,6 +79,10 @@ module Falcon
|
|
78
79
|
options[:port] = @options[:port]
|
79
80
|
end
|
80
81
|
|
82
|
+
if duration = @options[:timeout] and !duration.zero?
|
83
|
+
options[:timeout] = duration
|
84
|
+
end
|
85
|
+
|
81
86
|
return options
|
82
87
|
end
|
83
88
|
|
@@ -96,19 +101,30 @@ module Falcon
|
|
96
101
|
|
97
102
|
bound_endpoint = Async::Reactor.run do
|
98
103
|
Async::IO::SharedEndpoint.bound(endpoint)
|
99
|
-
end.
|
104
|
+
end.wait
|
100
105
|
|
101
|
-
Async.logger.info
|
106
|
+
Async.logger.info(endpoint) do
|
107
|
+
"Falcon taking flight! Using #{container_class} with concurrency: #{@options[:concurrency]}"
|
108
|
+
end
|
102
109
|
|
103
110
|
debug_trap = Async::IO::Trap.new(:USR1)
|
104
111
|
|
112
|
+
debug_trap.ignore!
|
113
|
+
|
114
|
+
if container_class.multiprocess?
|
115
|
+
Async.logger.info "Full status: kill -USR1 #{-Process.pid}"
|
116
|
+
end
|
117
|
+
|
105
118
|
container_class.new(concurrency: @options[:concurrency], name: "Falcon Server") do |task, instance|
|
106
119
|
task.async do
|
107
|
-
debug_trap.install!
|
108
|
-
|
120
|
+
if debug_trap.install!
|
121
|
+
Async.logger.info "Per-process status: kill -USR1 #{Process.pid}"
|
122
|
+
end
|
109
123
|
|
110
124
|
debug_trap.trap do
|
111
|
-
|
125
|
+
Async.logger.info(self) do |buffer|
|
126
|
+
task.reactor.print_hierarchy(buffer)
|
127
|
+
end
|
112
128
|
end
|
113
129
|
end
|
114
130
|
|
data/lib/falcon/verbose.rb
CHANGED
@@ -46,7 +46,7 @@ module Falcon
|
|
46
46
|
response = super
|
47
47
|
|
48
48
|
statistics.wrap(response) do |statistics, error|
|
49
|
-
@logger.info(request.authority) {"#{
|
49
|
+
@logger.info(request.authority) {"#{request.method} #{request.path} #{request.version} -> #{response.status} #{response.headers.to_h}; #{statistics.inspect}"}
|
50
50
|
|
51
51
|
@logger.error(request.authority) {"#{error.class}: #{error.message}"} if error
|
52
52
|
end
|
data/lib/falcon/version.rb
CHANGED
data/tasks/benchmark.rake
CHANGED
@@ -17,7 +17,7 @@ namespace :benchmark do
|
|
17
17
|
servers = [
|
18
18
|
["puma", "--bind", host.gsub("http", "tcp")],
|
19
19
|
["puma", "--workers", threads.to_s, "--bind", host.gsub("http", "tcp")],
|
20
|
-
["falcon", "--bind", host, "--config"]
|
20
|
+
["falcon", "serve", "--bind", host, "--config"]
|
21
21
|
]
|
22
22
|
|
23
23
|
endpoint = Async::HTTP::URLEndpoint.parse(host)
|
@@ -51,7 +51,7 @@ namespace :benchmark do
|
|
51
51
|
response.close
|
52
52
|
|
53
53
|
socket.close
|
54
|
-
rescue Errno::ECONNREFUSED
|
54
|
+
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
|
55
55
|
task.sleep 0.01
|
56
56
|
|
57
57
|
retry
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-protocol
|
@@ -24,20 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.10.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: async
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: async-io
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
47
|
+
version: '1.18'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
54
|
+
version: '1.18'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: async-http
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +72,14 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
75
|
+
version: 0.9.0
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
82
|
+
version: 0.9.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rack
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,16 +154,16 @@ dependencies:
|
|
140
154
|
name: bundler
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- - "
|
157
|
+
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
159
|
+
version: '0'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- - "
|
164
|
+
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rspec
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +211,8 @@ files:
|
|
197
211
|
- examples/beer/config.ru
|
198
212
|
- examples/benchmark/config.ru
|
199
213
|
- examples/hello/config.ru
|
214
|
+
- examples/redis/Gemfile
|
215
|
+
- examples/redis/config.ru
|
200
216
|
- examples/sinatra/Gemfile
|
201
217
|
- examples/sinatra/Gemfile.lock
|
202
218
|
- examples/sinatra/config.ru
|
@@ -240,8 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
256
|
- !ruby/object:Gem::Version
|
241
257
|
version: '0'
|
242
258
|
requirements: []
|
243
|
-
|
244
|
-
rubygems_version: 2.7.7
|
259
|
+
rubygems_version: 3.0.1
|
245
260
|
signing_key:
|
246
261
|
specification_version: 4
|
247
262
|
summary: A fast, asynchronous, rack-compatible web server.
|