falcon 0.55.0 → 0.55.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/falcon/body/request_finished.rb +61 -0
- data/lib/falcon/server.rb +9 -3
- data/lib/falcon/version.rb +1 -1
- data/readme.md +4 -4
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45c36302281a4c7947bc8c19869f93143254e821c0ab327b725aa8782dd710cb
|
|
4
|
+
data.tar.gz: c59ab82cc9babe0eea1a7ec74b2fdba4be6801dd7b1b05359fec6a2f8ec0db91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2242015bc8980ebef3ae53fb2bf8db8040ef943bada60bb801cd65e849cfc68f8586b6a33e050053270cd9bd10ea9e5c778de117adb82353ecc47d24439bfb7f
|
|
7
|
+
data.tar.gz: 522154fa107e97fa4a8b72e997f71ab7afcf4e8a5699cb741f6d16aa2720b722a664dae052c82130df930af3430aa1d531a705ac59081658074008b4e58ded6a
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2025, 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.
|
|
68
|
-
|
|
69
|
-
|
|
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.
|
data/lib/falcon/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -47,6 +47,10 @@ 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.1
|
|
51
|
+
|
|
52
|
+
- `requests_active` is decremented after the response body is closed, including `rack.response_finished` callbacks.
|
|
53
|
+
|
|
50
54
|
### v0.55.0
|
|
51
55
|
|
|
52
56
|
- **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
|
|
@@ -92,10 +96,6 @@ Please see the [project releases](https://socketry.github.io/falcon/releases/ind
|
|
|
92
96
|
|
|
93
97
|
- Improve compatibility of rackup handler w.r.t. sinatra.
|
|
94
98
|
|
|
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,9 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.55.1
|
|
4
|
+
|
|
5
|
+
- `requests_active` is decremented after the response body is closed, including `rack.response_finished` callbacks.
|
|
6
|
+
|
|
3
7
|
## v0.55.0
|
|
4
8
|
|
|
5
9
|
- **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
|
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.55.
|
|
4
|
+
version: 0.55.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -252,6 +252,7 @@ files:
|
|
|
252
252
|
- context/rails-integration.md
|
|
253
253
|
- context/websockets.md
|
|
254
254
|
- lib/falcon.rb
|
|
255
|
+
- lib/falcon/body/request_finished.rb
|
|
255
256
|
- lib/falcon/command.rb
|
|
256
257
|
- lib/falcon/command/host.rb
|
|
257
258
|
- lib/falcon/command/paths.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|