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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ad0fb3facc056827b3f6d86b9f7d3dbd8c8e8a7
4
- data.tar.gz: 11fd7d0b44d280815bbae15a6278594f788324fd
3
+ metadata.gz: 9a067158b414952647b19847e09219b0d5c63249
4
+ data.tar.gz: 746c6aceae8e30907ad97b650c57109ccb51de1a
5
5
  SHA512:
6
- metadata.gz: 2dd102500ba56111af17b1237a7b9ac6d0d65428fb58ebb3cb685bef2beb493ab5379310edbad5553470c51eda490f32a4296f563dc7c6d3686287143bf0c077
7
- data.tar.gz: 937b96dc8903ec42c5e7572c29c83ff7e2fc18c10eff01a759cb240d8a05fc9a91cef5a620719573583a4af5602d01b11ad6da620f192ae37f70656a3309cb78
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::Address.tcp(host, port)])
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::Address.tcp('127.0.0.1', 9294, reuse_port: true)
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::Address.tcp('127.0.0.1', 9294, reuse_port: true)
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::Address.tcp('127.0.0.1', 9294, reuse_port: true)
49
+ Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
50
50
  ], app)
51
51
 
52
52
  process_count = Etc.nprocessors
@@ -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.2")
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")
@@ -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::Address.parse(@options[:bind], reuse_port: true)
58
+ Async::IO::Endpoint.parse(@options[:bind], reuse_port: true)
59
59
  ])
60
60
 
61
61
  server.run
@@ -65,10 +65,15 @@ module Falcon
65
65
  'SERVER_PROTOCOL' => request.version,
66
66
  'rack.url_scheme' => 'http',
67
67
 
68
- 'SERVER_NAME' => server_name,
69
- 'SERVER_PORT' => server_port,
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
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.3.1"
22
+ VERSION = "0.4.1"
23
23
  end
@@ -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
- command = ::Falcon::Command::Serve.new([])
19
+ addresses = addresses_for(**options)
11
20
 
12
- process_count = command.options[:process]
21
+ server = ::Falcon::Server.new(app, addresses)
13
22
 
14
- pids = process_count.times.collect do
15
- fork do
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.3.1
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-06-20 00:00:00.000000000 Z
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.2'
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.2'
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.10
165
+ rubygems_version: 2.6.12
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: ''