falcon 0.55.0 → 0.55.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aa8fb7fb61e5c4112b6e7e3423a59e27a0f00555edd04ab381ca58f064b10cd
4
- data.tar.gz: a8a3a69df547475b9fd306f0bedd3e0f4836f1d3f42be43f1f6b1d53746b82e5
3
+ metadata.gz: 3e901867477864a82832904cbaa1662105e6dce12190e057d457a666fa3dfe42
4
+ data.tar.gz: 523e181a6685bfe398bc5630076ab8e76642bf47181d4e20c62192813f121712
5
5
  SHA512:
6
- metadata.gz: 2dca19722a68b6bd56f1caf3639cc5b4f952a6d908a5e2e36f10cf1e6a3e733d1d423c1713dab0ac8dc5e1adc595d2d6acb345a24d868c85e1b6ca706164fd00
7
- data.tar.gz: 6d1ffeb9711b90027841489a348322fe955004cab78a2aa5a26a6ec61be6613013dc33d87b675776338b91aa2715cf3423959e05947e8e3ff42e886e50727666
6
+ metadata.gz: 0eb64a874478507caeafefb4c83b108cfa7b00326cf69ce7581ab534e9466048dea1572b66044f06ee19b21998fafad32cf5de3ea050f6ae0f32b1743424ef2e
7
+ data.tar.gz: 3f041a4ebdf07b1063373a27e7151b4f8380f4f440b34a773f27b0b6761d64f721209c5a7d2366f1210e1be1d3042d1e8bed117a77a7ce81d9335274636fe656
checksums.yaml.gz.sig CHANGED
Binary file
@@ -56,18 +56,22 @@ service "supervisor" do
56
56
  end
57
57
  ~~~
58
58
 
59
- These configuration blocks are evaluated using the [async-service](https://github.com/socketry/async-service) gem. The supervisor is an independent service which monitors the health of the application and can restart it if necessary. Other services like background job processors can be added to the configuration.
59
+ These configuration blocks are evaluated using the [async-service](https://github.com/socketry/async-service) gem. This configuration will bind Falcon to an [IPC socket](https://en.wikipedia.org/wiki/Unix_domain_socket) and is designed to be used with a reverse proxy such as [`falcon virtual`](#falcon-virtual).
60
+
61
+ The supervisor is an independent service which monitors the health of the application and can restart it if necessary. Other services like background job processors can be added to the configuration.
60
62
 
61
63
  ### Environments
62
64
 
63
65
  The service blocks define configuration that is loaded by the service layer to control how the service is run. The `service ... do` block defines the service name and the environment in which it runs. Different modules can be included to provide different functionality, such as `Falcon::Environment::Rack` for Rack applications, or `Falcon::Environment::LetsEncryptTLS` for automatic TLS certificate management.
64
66
 
67
+ **NOTE**: Falcon does not provision or renew certificates automatically. Use a tool like [certbot](https://certbot.eff.org) to provision your certificate and the `LetsEncryptTLS` environment will automatically read it in.
68
+
65
69
  ### Application Configuration
66
70
 
67
71
  The environment configuration is defined in the `Falcon::Environment` module. The {ruby Falcon::Environment::Application} environment supports the generic virtual host functionality, but you can customise any parts of the configuration, e.g. to bind a production host to `localhost:3000` using plaintext HTTP/2:
68
72
 
69
73
  ~~~ ruby
70
- #!/usr/bin/env falcon host
74
+ #!/usr/bin/env falcon-host
71
75
  # frozen_string_literal: true
72
76
 
73
77
  require "falcon/environment/rack"
@@ -76,12 +80,54 @@ require "async/service/supervisor"
76
80
  hostname = File.basename(__dir__)
77
81
  service hostname do
78
82
  include Falcon::Environment::Rack
79
- include Falcon::Environment::LetsEncryptTLS
80
83
 
81
84
  endpoint do
82
85
  Async::HTTP::Endpoint
83
86
  .parse('http://localhost:3000')
84
- .with(protocol: Async::HTTP::Protocol::HTTP2)
87
+ .with(
88
+ protocol: Async::HTTP::Protocol::HTTP2
89
+ )
90
+ end
91
+ end
92
+
93
+ service "supervisor" do
94
+ include Async::Service::Supervisor::Environment
95
+ end
96
+ ~~~
97
+
98
+ You can verify this is working using the [`nghttp2` client](https://nghttp2.org): `nghttp -v http://localhost:3000`. This will not work in a browser as they mandate TLS for HTTP/2 connections.
99
+
100
+ #### Self-signed certificate
101
+
102
+ You can use a self-signed certificate to test your server configuration locally. First, provision a certificate using the [`localhost` gem](https://github.com/socketry/localhost):
103
+
104
+ ```
105
+ $ bundle exec bake localhost:install
106
+ ```
107
+
108
+ You may be prompted for a password to install the certificate. This is the password for your local keychain.
109
+
110
+ Then, add the `SelfSignedTLS` environment to your configuration and set up the SSL context:
111
+
112
+ ~~~ ruby
113
+ #!/usr/bin/env falcon-host
114
+ # frozen_string_literal: true
115
+
116
+ require "falcon/environment/rack"
117
+ require "async/service/supervisor"
118
+
119
+ hostname = File.basename(__dir__)
120
+ service hostname do
121
+ include Falcon::Environment::Rack
122
+ include Falcon::Environment::SelfSignedTLS
123
+
124
+ endpoint do
125
+ Async::HTTP::Endpoint
126
+ .parse('https://localhost:3000')
127
+ .with(
128
+ protocol: Async::HTTP::Protocol::HTTP2,
129
+ ssl_context: ssl_context
130
+ )
85
131
  end
86
132
  end
87
133
 
@@ -90,7 +136,7 @@ service "supervisor" do
90
136
  end
91
137
  ~~~
92
138
 
93
- You can verify this is working using `nghttp -v http://localhost:3000`.
139
+ You should now be able to access your server at `https://localhost:3000` in your browser.
94
140
 
95
141
  #### Application Configuration Example for Heroku
96
142
 
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ require "protocol/http/body/wrapper"
7
+
8
+ module Falcon
9
+ # @namespace
10
+ module Body
11
+ # Wraps a response body and decrements a metric after the body is closed.
12
+ #
13
+ # Runs close on the underlying body first (which invokes rack.response_finished),
14
+ # then decrements the metric. Use this so requests_active stays elevated until
15
+ # the request is fully finished (including response_finished callbacks).
16
+ class RequestFinished < Protocol::HTTP::Body::Wrapper
17
+ # Wrap a response body with a metric. If the body is nil or empty, decrements immediately.
18
+ #
19
+ # @parameter message [Protocol::HTTP::Response] The response whose body to wrap.
20
+ # @parameter metric [Async::Utilization::Metric] The metric to decrement when the body is closed.
21
+ # @returns [Protocol::HTTP::Response] The message (modified in place).
22
+ def self.wrap(message, metric)
23
+ if body = message&.body and !body.empty?
24
+ message.body = new(body, metric)
25
+ else
26
+ metric.decrement
27
+ end
28
+
29
+ message
30
+ end
31
+
32
+ # @parameter body [Protocol::HTTP::Body::Readable] The body to wrap.
33
+ # @parameter metric [Async::Utilization::Metric] The metric to decrement on close.
34
+ def initialize(body, metric)
35
+ super(body)
36
+
37
+ @metric = metric
38
+ end
39
+
40
+ # @returns [Boolean] False, the wrapper does not support rewinding.
41
+ def rewindable?
42
+ false
43
+ end
44
+
45
+ # @returns [Boolean] False, rewinding is not supported.
46
+ def rewind
47
+ false
48
+ end
49
+
50
+ # Closes the underlying body (invoking rack.response_finished), then decrements the metric.
51
+ #
52
+ # @parameter error [Exception, nil] Optional error that caused the close.
53
+ def close(error = nil)
54
+ super
55
+
56
+ @metric&.decrement
57
+ @metric = nil
58
+ end
59
+ end
60
+ end
61
+ end
data/lib/falcon/server.rb CHANGED
@@ -10,6 +10,7 @@ require "protocol/http/content_encoding"
10
10
 
11
11
  require "async/http/cache"
12
12
  require "async/utilization"
13
+ require_relative "body/request_finished"
13
14
  require_relative "middleware/verbose"
14
15
  require "protocol/rack"
15
16
 
@@ -62,11 +63,16 @@ module Falcon
62
63
  end
63
64
 
64
65
  # Handle a request and track request statistics.
66
+ #
67
+ # Uses manual increment/decrement so requests_active stays elevated until the
68
+ # response body is closed (including rack.response_finished). The
69
+ # Body::RequestFinished wrapper runs the decrement after the body closes,
70
+ # so response_finished callbacks are counted as active.
65
71
  def call(...)
66
72
  @requests_total_metric.increment
67
- @requests_active_metric.track do
68
- super
69
- end
73
+ @requests_active_metric.increment
74
+
75
+ return Body::RequestFinished.wrap(super, @requests_active_metric)
70
76
  end
71
77
 
72
78
  # Generates a human-readable string representing the current statistics.
@@ -5,7 +5,6 @@
5
5
  # Copyright, 2020, by Daniel Evans.
6
6
 
7
7
  require "async/service/managed/service"
8
- require "async/service/supervisor/supervised"
9
8
  require "async/http/endpoint"
10
9
 
11
10
  require_relative "../server"
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Falcon
8
- VERSION = "0.55.0"
8
+ VERSION = "0.55.2"
9
9
  end
data/license.md CHANGED
@@ -28,6 +28,7 @@ Copyright, 2024, by Ismael Celis.
28
28
  Copyright, 2025, by Pierre Montelle.
29
29
  Copyright, 2025, by Jared Smith.
30
30
  Copyright, 2025, by Yoji Shidara.
31
+ Copyright, 2026, by Ayush Newatia.
31
32
 
32
33
  Permission is hereby granted, free of charge, to any person obtaining a copy
33
34
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -47,6 +47,14 @@ Please see the [project documentation](https://socketry.github.io/falcon/) for m
47
47
 
48
48
  Please see the [project releases](https://socketry.github.io/falcon/releases/index) for all releases.
49
49
 
50
+ ### v0.55.2
51
+
52
+ - Remove unnecessary require for `async/service/supervisor/supervised`."
53
+
54
+ ### v0.55.1
55
+
56
+ - `requests_active` is decremented after the response body is closed, including `rack.response_finished` callbacks.
57
+
50
58
  ### v0.55.0
51
59
 
52
60
  - **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
@@ -88,14 +96,6 @@ Please see the [project releases](https://socketry.github.io/falcon/releases/ind
88
96
  - [Falcon Server Container Health Checks](https://socketry.github.io/falcon/releases/index#falcon-server-container-health-checks)
89
97
  - [Falcon Server Process Title](https://socketry.github.io/falcon/releases/index#falcon-server-process-title)
90
98
 
91
- ### v0.48.4
92
-
93
- - Improve compatibility of rackup handler w.r.t. sinatra.
94
-
95
- ### v0.47.8
96
-
97
- - Fix Falcon Supervisor implementation: due to invalid code, it was unable to start.
98
-
99
99
  ## Contributing
100
100
 
101
101
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.55.2
4
+
5
+ - Remove unnecessary require for `async/service/supervisor/supervised`."
6
+
7
+ ## v0.55.1
8
+
9
+ - `requests_active` is decremented after the response body is closed, including `rack.response_finished` callbacks.
10
+
3
11
  ## v0.55.0
4
12
 
5
13
  - **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ��TM�!�KCl׼�4uz�z�[�>2̢��C5&�$�d�~�~�7 �{
2
- �Oz ����E���8�o�g����E�$���m �B����^ᎆ�0M�\}`��ޏ�Ƽ���h�<�r~)W^['�]_�@�㪫N�g���U���w���ٯ�a�K�;㿂���d2���F.�a�I�f���[��X9�sүи��w�(L��c(����Fޅ. &�a��M���u��FWn�
1
+ q,4��_�:�=�"��ߙ����t!&sל�c\�qbNgL�>>S�}!!�Db�Y�,w����kC����U���������+''��[x٥�L���!�+�L��f��&`Go���XZ����^pG`��
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.55.0
4
+ version: 0.55.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -15,6 +15,7 @@ authors:
15
15
  - Peter Schrammel
16
16
  - Sho Ito
17
17
  - Adam Daniels
18
+ - Ayush Newatia
18
19
  - Colby Swandale
19
20
  - Daniel Evans
20
21
  - Ismael Celis
@@ -252,6 +253,7 @@ files:
252
253
  - context/rails-integration.md
253
254
  - context/websockets.md
254
255
  - lib/falcon.rb
256
+ - lib/falcon/body/request_finished.rb
255
257
  - lib/falcon/command.rb
256
258
  - lib/falcon/command/host.rb
257
259
  - lib/falcon/command/paths.rb
metadata.gz.sig CHANGED
Binary file