falcon 0.20.0 → 0.20.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
  SHA256:
3
- metadata.gz: 9b2de4bddd24124f6859b6fe9abf37624537b3d9175cab2d3925a897cab1ca30
4
- data.tar.gz: ca3ca0154ec2abf520c3b2a6c0f231bc66833689236a9144ce7832e390b9a894
3
+ metadata.gz: 94bed6aa04bd0bb1f431f516e6d79e86598ab611afc62ebedaafe56eea99df09
4
+ data.tar.gz: c1043b1e89f86f8acd4f3731f23ccd2685866bc36eaf80b38debd1a763f9cf42
5
5
  SHA512:
6
- metadata.gz: aee2014818ce576facb26f073df66c15cfc866f4aa9993185d98f0ebc774547fcb043a9de72f36cbaa8c977a3cdcd6af998b4860a9ad63d3cd41676ed8a5e5aa
7
- data.tar.gz: 15a9f6d3e42d5333f533b3e005d0bf6c6fcbe533814221f8ee02b47e2152b58e91da948d607ad63d45225acc76736824baf743029b44435fe315dd872c882e07
6
+ metadata.gz: '02499bd4364da608ed79a7405b527566a68c3337e8c5df94fcd8852f32a07d2478333bd276308fb2efe62203152474800ef4d809ae45d943628537d09b5acda3'
7
+ data.tar.gz: 6e65a21e8bf20a5b3c0b3dfbe58335259ea6bf9754b7fb1643fd79650df149b848dea4c2727f0c3a32001bfcfe955b1f7b6dbfab610a9f12895a718d1381e610
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("http-protocol", "~> 0.10.0")
19
+ spec.add_dependency("http-protocol", "~> 0.11.0")
20
20
 
21
21
  spec.add_dependency("async", "~> 1.13")
22
22
  spec.add_dependency("async-io", "~> 1.18")
@@ -31,9 +31,9 @@ module Falcon
31
31
  # Wraps an array into a buffered body.
32
32
  def self.wrap(status, headers, body)
33
33
  # In no circumstance do we want this header propagating out:
34
- if content_length = headers.delete(CONTENT_LENGTH)
34
+ if length = headers.delete(CONTENT_LENGTH)
35
35
  # We don't really trust the user to provide the right length to the transport.
36
- content_length = Integer(content_length)
36
+ length = Integer(length)
37
37
  end
38
38
 
39
39
  if body.is_a?(Async::HTTP::Body::Readable)
@@ -41,8 +41,11 @@ module Falcon
41
41
  elsif status == 200 and body.respond_to?(:to_path)
42
42
  # Don't mangle partial responsese (206)
43
43
  return Async::HTTP::Body::File.open(body.to_path)
44
+ elsif body.is_a? Array
45
+ length ||= body.sum{|chunk| chunk.bytesize}
46
+ return self.new(headers, body, length)
44
47
  else
45
- return self.new(headers, body, content_length)
48
+ return self.new(headers, body, length)
46
49
  end
47
50
  end
48
51
 
@@ -50,8 +53,7 @@ module Falcon
50
53
  @length = length
51
54
  @body = body
52
55
 
53
- # An enumerator over the rack response body:
54
- @chunks = body.to_enum(:each)
56
+ @chunks = nil
55
57
  end
56
58
 
57
59
  # The rack response body.
@@ -67,20 +69,26 @@ module Falcon
67
69
  def close(error = nil)
68
70
  if @body and @body.respond_to?(:close)
69
71
  @body.close
70
- @body = nil
71
72
  end
72
73
 
74
+ @body = nil
73
75
  @chunks = nil
74
76
 
75
77
  super
76
78
  end
77
79
 
80
+ def each(&block)
81
+ @body.each(&block)
82
+ ensure
83
+ self.close($!)
84
+ end
85
+
78
86
  def read
79
- if @chunks
80
- return @chunks.next
81
- end
87
+ @chunks ||= @body.to_enum(:each)
88
+
89
+ return @chunks.next
82
90
  rescue StopIteration
83
- nil
91
+ return nil
84
92
  end
85
93
 
86
94
  def inspect
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.20.0"
22
+ VERSION = "0.20.1"
23
23
  end
data/tasks/benchmark.rake CHANGED
@@ -14,12 +14,17 @@ namespace :benchmark do
14
14
 
15
15
  threads = Etc.nprocessors
16
16
 
17
+ perf = ["perf", "record", "-F", "max", "-a", "--"]
18
+
17
19
  servers = [
18
- ["puma", "--bind", host.gsub("http", "tcp")],
20
+ # ["puma", "--bind", host.gsub("http", "tcp")],
19
21
  ["puma", "--workers", threads.to_s, "--bind", host.gsub("http", "tcp")],
22
+ # ["rbspy", "record", "--", "falcon", "serve", "--threaded", "--bind", host, "--config"]
20
23
  ["falcon", "serve", "--bind", host, "--config"]
21
24
  ]
22
25
 
26
+ Async.logger.info!
27
+
23
28
  endpoint = Async::HTTP::URLEndpoint.parse(host)
24
29
 
25
30
  servers.each do |command|
@@ -42,12 +47,14 @@ namespace :benchmark do
42
47
 
43
48
  socket = endpoint.connect
44
49
 
45
- request = Async::HTTP::Request.new("http", "localhost", "GET", "/small")
50
+ request = Async::HTTP::Request.new("http", "localhost", "GET", "/big")
46
51
  stream = Async::IO::Stream.new(socket)
47
52
  protocol = Async::HTTP::Protocol::HTTP1.client(stream)
48
53
 
49
54
  response = protocol.call(request)
50
55
 
56
+ Async.logger.info(response, "Headers:", response.headers.to_h) {"Response body size: #{response.read.bytesize}"}
57
+
51
58
  response.close
52
59
 
53
60
  socket.close
@@ -59,13 +66,17 @@ namespace :benchmark do
59
66
 
60
67
  end_time = Async::Clock.now
61
68
 
62
- $stderr.puts "** Took #{end_time - start_time}s to start #{command.first}."
69
+ Async.logger.info(command) {"** Took #{end_time - start_time}s to first response."}
63
70
 
64
71
  threads.times do |n|
65
72
  c = (2**n).to_s
66
73
  puts "Running #{command.first} with #{c} concurrent connections..."
67
74
 
68
- status = Async::Process.spawn("wrk", "-c", c.to_s, "-t", (n+1).to_s, "-d", "1", "#{host}/big")
75
+ # Async::Process.spawn("curl", "-v", "#{host}/small")
76
+
77
+ # Async::Process.spawn("ab", "-n", "2000", "#{host}/small")
78
+
79
+ Async::Process.spawn("wrk", "-c", c.to_s, "-t", (n+1).to_s, "-d", "2", "#{host}/big")
69
80
  end
70
81
  ensure
71
82
  server_task.stop
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.20.0
4
+ version: 0.20.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: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-protocol
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.0
19
+ version: 0.11.0
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.10.0
26
+ version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: async
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  - !ruby/object:Gem::Version
257
257
  version: '0'
258
258
  requirements: []
259
- rubygems_version: 3.0.1
259
+ rubygems_version: 3.0.2
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: A fast, asynchronous, rack-compatible web server.