falcon 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/Rakefile +3 -3
- data/falcon.gemspec +1 -1
- data/lib/falcon/command.rb +1 -1
- data/lib/falcon/server.rb +7 -2
- data/lib/falcon/version.rb +1 -1
- data/lib/rack/handler/falcon.rb +13 -22
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a067158b414952647b19847e09219b0d5c63249
|
4
|
+
data.tar.gz: 746c6aceae8e30907ad97b650c57109ccb51de1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c5b9b4517339fdc5f4b5abe7061eddb91e7017a276ca50d65bd273acb1ba105bc4e37241523fc87eb2e5c8307d220076b3eea8a45eff3dba58c5c488e3370e2
|
7
|
+
data.tar.gz: dfda4d0304bc727fc53ca2477737fbd6c7428814944568fd6170c85a0dac7780f8e0c70c2962eb3c517c2fdc78960d4e959a942a254fa1b33603506a19aa4c49
|
data/README.md
CHANGED
@@ -46,13 +46,21 @@ Capybara.register_server :falcon do |app, port, host|
|
|
46
46
|
require 'falcon/server'
|
47
47
|
|
48
48
|
Async::Reactor.run do
|
49
|
-
server = Falcon::Server.new(app, [Async::IO::
|
49
|
+
server = Falcon::Server.new(app, [Async::IO::Endpoint.tcp(host, port)])
|
50
50
|
|
51
51
|
server.run
|
52
52
|
end
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
56
|
+
### Using with Rackup
|
57
|
+
|
58
|
+
You can invoke Falcon via `rackup`:
|
59
|
+
|
60
|
+
rackup --server falcon
|
61
|
+
|
62
|
+
This will run a single-threaded instance of Falcon.
|
63
|
+
|
56
64
|
### Deploying with Passenger
|
57
65
|
|
58
66
|
You can run Falcon within Passenger to improve asyncronicity by using the `Falcon::Hijack` middleware. The first request from a client will be parsed by Passenger, but `rack.hijack` allows us to start parsing requests using Falcon within a separate `Async::Reactor` which reduces latency and avoids blocking IO where possible.
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ task :server do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
server = Async::HTTP::Server.new([
|
17
|
-
Async::IO::
|
17
|
+
Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
|
18
18
|
], app)
|
19
19
|
|
20
20
|
Async::Reactor.run do
|
@@ -27,7 +27,7 @@ task :client do
|
|
27
27
|
require 'async/http/client'
|
28
28
|
|
29
29
|
client = Async::HTTP::Client.new([
|
30
|
-
Async::IO::
|
30
|
+
Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
|
31
31
|
])
|
32
32
|
|
33
33
|
Async::Reactor.run do
|
@@ -46,7 +46,7 @@ task :wrk do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
server = Async::HTTP::Server.new([
|
49
|
-
Async::IO::
|
49
|
+
Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
|
50
50
|
], app)
|
51
51
|
|
52
52
|
process_count = Etc.nprocessors
|
data/falcon.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency("async-http", "~> 0.
|
19
|
+
spec.add_dependency("async-http", "~> 0.3")
|
20
20
|
spec.add_dependency("async-container", "~> 0.1")
|
21
21
|
|
22
22
|
spec.add_dependency("rack", ">= 1.0")
|
data/lib/falcon/command.rb
CHANGED
@@ -55,7 +55,7 @@ module Falcon
|
|
55
55
|
|
56
56
|
Async::Container.new(concurrency: @options[:concurrency]) do
|
57
57
|
server = Falcon::Server.new(app, [
|
58
|
-
Async::IO::
|
58
|
+
Async::IO::Endpoint.parse(@options[:bind], reuse_port: true)
|
59
59
|
])
|
60
60
|
|
61
61
|
server.run
|
data/lib/falcon/server.rb
CHANGED
@@ -65,10 +65,15 @@ module Falcon
|
|
65
65
|
'SERVER_PROTOCOL' => request.version,
|
66
66
|
'rack.url_scheme' => 'http',
|
67
67
|
|
68
|
-
'
|
69
|
-
'
|
68
|
+
# I'm not sure what sane defaults should be here:
|
69
|
+
'SERVER_NAME' => server_name || '',
|
70
|
+
'SERVER_PORT' => server_port || '',
|
70
71
|
}.merge(request.headers)
|
71
72
|
|
73
|
+
if content_type = request.headers['HTTP_CONTENT_TYPE']
|
74
|
+
env['CONTENT_TYPE'] = content_type
|
75
|
+
end
|
76
|
+
|
72
77
|
if remote_address = peer.remote_address
|
73
78
|
env['REMOTE_ADDR'] = remote_address.ip_address if remote_address.ip?
|
74
79
|
end
|
data/lib/falcon/version.rb
CHANGED
data/lib/rack/handler/falcon.rb
CHANGED
@@ -6,32 +6,23 @@ require_relative '../../falcon'
|
|
6
6
|
module Rack
|
7
7
|
module Handler
|
8
8
|
module Falcon
|
9
|
+
def self.addresses_for(**options)
|
10
|
+
host = options[:Host] || 'localhost'
|
11
|
+
port = Integer(options[:Port] || 9292)
|
12
|
+
|
13
|
+
return [
|
14
|
+
Async::IO::Endpoint.tcp(host, port)
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
9
18
|
def self.run(app, **options)
|
10
|
-
|
19
|
+
addresses = addresses_for(**options)
|
11
20
|
|
12
|
-
|
21
|
+
server = ::Falcon::Server.new(app, addresses)
|
13
22
|
|
14
|
-
|
15
|
-
|
16
|
-
puts "Serving from pid #{Process.pid}"
|
17
|
-
command.run(app, options)
|
18
|
-
end
|
23
|
+
Async::Reactor.run do
|
24
|
+
server.run
|
19
25
|
end
|
20
|
-
|
21
|
-
sleep
|
22
|
-
ensure
|
23
|
-
pids.each do |pid|
|
24
|
-
Process.kill(:TERM, pid) rescue nil
|
25
|
-
Process.wait(pid)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.valid_options
|
30
|
-
{
|
31
|
-
"host=HOST" => "Hostname to listen on (default: localhost)",
|
32
|
-
"port=PORT" => "Port to listen on (default: 8080)",
|
33
|
-
"verbose" => "Don't report each request (default: false)"
|
34
|
-
}
|
35
26
|
end
|
36
27
|
end
|
37
28
|
|
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.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: async-container
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.6.
|
165
|
+
rubygems_version: 2.6.12
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: ''
|