falcon 0.40.0 → 0.40.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: cb44add9ea622a70918ed4b2287db8db8e233b143575dbefe86e4eeb93d6215f
4
- data.tar.gz: a63f6a8d28ca6573f1b534ce8c27622ae5ec65046b986dbb3ed238d3ed147bcc
3
+ metadata.gz: 94f85c9e2ed95f6a43fda46cc07a986436ec7d874294b28288bcb004d269ea3c
4
+ data.tar.gz: f56850aab821d12cd73cdc1545ad2691bce81d1121ae543feb3d29f6e8ae28da
5
5
  SHA512:
6
- metadata.gz: 6d56ce43c1d153a1a85cebdb4c09c1da0592b7cc8a68a4c7a6d1e1df18c548c7893fb56248dbcfba4c87fa8b0b4e0e27037c75cc79d6d9f3de97ea66ba285d2f
7
- data.tar.gz: ef744900cbc8b88ddfe9b9a107f87cde89b9067d9f9c5c9e41dadf3ace45f72aaec5261940b2fcfee5aeb683213d5476046746305fbb1e279ec82a511266600d
6
+ metadata.gz: 047ac6d846d54362c8cc220f0264c60f9c951c557a61ca9c34636a93198acf04ab1b6e0b7ff10a684a8700f4b6a158dd57abf453cfa71bd5e9dee949eeedccdf
7
+ data.tar.gz: 425b8131c9cbbe18684492213351e480a42d8037fc198c234ce7cd19e5f3f61b5bf59145b8335e8508928ee766ddcbff8992925084c2f5dbd5cfe1f0207de03b
checksums.yaml.gz.sig CHANGED
Binary file
@@ -22,13 +22,15 @@
22
22
 
23
23
  require 'openssl/x509'
24
24
 
25
- module OpenSSL::X509
26
- CERTIFICATE_PATTERN = /-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m
27
-
28
- # An extension to load an array of certificates from a file at the given path.
29
- def self.load_certificates(path)
30
- File.read(path).scan(CERTIFICATE_PATTERN).collect do |text|
31
- Certificate.new(text)
25
+ module OpenSSL
26
+ module X509
27
+ CERTIFICATE_PATTERN = /-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m
28
+
29
+ # An extension to load an array of certificates from a file at the given path.
30
+ def self.load_certificates(path)
31
+ File.read(path).scan(CERTIFICATE_PATTERN).collect do |text|
32
+ Certificate.new(text)
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -87,9 +87,9 @@ module Falcon
87
87
 
88
88
  begin
89
89
  service.stop
90
- rescue
90
+ rescue => error
91
91
  failed = true
92
- Console.logger.error(self, $!)
92
+ Console.logger.error(self, error)
93
93
  end
94
94
  end
95
95
 
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Falcon
24
- VERSION = "0.40.0"
24
+ VERSION = "0.40.1"
25
25
  end
@@ -4,16 +4,16 @@ require 'rack/handler'
4
4
 
5
5
  require_relative '../../falcon'
6
6
 
7
- require 'async/reactor'
7
+ require 'kernel/sync'
8
8
  require 'async/io/host_endpoint'
9
+ require 'async/io/notification'
9
10
 
10
11
  module Rack
11
12
  module Handler
12
13
  # The falcon adaptor for the `rackup` executable.
13
- module Falcon
14
+ class Falcon
14
15
  # The default scheme.
15
16
  SCHEME = "http"
16
- NAME = :falcon
17
17
 
18
18
  # Generate an endpoint for the given `rackup` options.
19
19
  # @returns [Async::IO::Endpoint]
@@ -27,20 +27,55 @@ module Rack
27
27
  # Run the specified app using the given options:
28
28
  # @parameter app [Object] The rack middleware.
29
29
  def self.run(app, **options)
30
- endpoint = endpoint_for(**options)
31
-
32
30
  app = ::Falcon::Adapters::Rack.new(app)
33
31
  app = ::Falcon::Adapters::Rewindable.new(app)
34
-
35
- server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
36
- yield server if block_given?
37
-
38
- Async::Reactor.run do
39
- server.run
32
+
33
+ Sync do |task|
34
+ endpoint = endpoint_for(**options)
35
+ server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
36
+
37
+ server_task = task.async do
38
+ server.run.each(&:wait)
39
+ end
40
+
41
+ wrapper = self.new(server, task)
42
+
43
+ yield wrapper if block_given?
44
+
45
+ server_task.wait
46
+ ensure
47
+ server_task.stop
48
+ wrapper.close
49
+ end
50
+ end
51
+
52
+ def initialize(server, task)
53
+ @server = server
54
+ @task = task
55
+
56
+ @notification = Async::IO::Notification.new
57
+
58
+ @waiter = @task.async(transient: true) do
59
+ @notification.wait
60
+
61
+ @task&.stop
62
+ @task = nil
40
63
  end
41
64
  end
65
+
66
+ def stop
67
+ @notification&.signal
68
+ end
69
+
70
+ def close
71
+ @notification&.close
72
+ @notification = nil
73
+
74
+ @waiter&.stop
75
+ @waiter = nil
76
+ end
42
77
  end
43
-
44
- register Falcon::NAME, Falcon
78
+
79
+ register :falcon, Falcon
45
80
  end
46
81
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.0
4
+ version: 0.40.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -53,7 +53,7 @@ cert_chain:
53
53
  RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
54
54
  HiLJ8VOFx6w=
55
55
  -----END CERTIFICATE-----
56
- date: 2022-07-17 00:00:00.000000000 Z
56
+ date: 2022-07-19 00:00:00.000000000 Z
57
57
  dependencies:
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: async
metadata.gz.sig CHANGED
Binary file