falcon 0.54.3 → 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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/context/deployment.md +5 -5
  4. data/lib/falcon/body/request_finished.rb +61 -0
  5. data/lib/falcon/command/host.rb +2 -2
  6. data/lib/falcon/command/paths.rb +3 -3
  7. data/lib/falcon/command/proxy.rb +8 -3
  8. data/lib/falcon/command/redirect.rb +11 -3
  9. data/lib/falcon/command/serve.rb +14 -4
  10. data/lib/falcon/command/top.rb +2 -2
  11. data/lib/falcon/command/virtual.rb +6 -2
  12. data/lib/falcon/command.rb +2 -1
  13. data/lib/falcon/composite_server.rb +1 -1
  14. data/lib/falcon/environment/configured.rb +4 -2
  15. data/lib/falcon/environment/lets_encrypt_tls.rb +1 -3
  16. data/lib/falcon/environment/proxy.rb +6 -11
  17. data/lib/falcon/environment/rack.rb +1 -3
  18. data/lib/falcon/environment/rackup.rb +7 -1
  19. data/lib/falcon/environment/redirect.rb +8 -2
  20. data/lib/falcon/environment/self_signed_tls.rb +1 -3
  21. data/lib/falcon/environment/server.rb +2 -2
  22. data/lib/falcon/environment/tls.rb +1 -2
  23. data/lib/falcon/environment/virtual.rb +4 -1
  24. data/lib/falcon/environment.rb +1 -4
  25. data/lib/falcon/middleware/proxy.rb +6 -1
  26. data/lib/falcon/middleware/redirect.rb +5 -1
  27. data/lib/falcon/proxy_endpoint.rb +3 -1
  28. data/lib/falcon/rackup/handler.rb +7 -1
  29. data/lib/falcon/railtie.rb +2 -1
  30. data/lib/falcon/server.rb +30 -23
  31. data/lib/falcon/service/server.rb +6 -3
  32. data/lib/falcon/tls.rb +2 -1
  33. data/lib/falcon/version.rb +3 -2
  34. data/lib/falcon.rb +1 -1
  35. data/lib/rack/handler/falcon.rb +3 -1
  36. data/lib/rackup/handler/falcon.rb +3 -1
  37. data/license.md +1 -1
  38. data/readme.md +11 -10
  39. data/releases.md +11 -0
  40. data.tar.gz.sig +0 -0
  41. metadata +15 -17
  42. metadata.gz.sig +0 -0
  43. data/bake/falcon/supervisor.rb +0 -8
  44. data/lib/falcon/configuration.rb +0 -90
  45. data/lib/falcon/environment/supervisor.rb +0 -23
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2025, by Samuel Williams.
4
+ # Copyright, 2018-2026, by Samuel Williams.
5
5
 
6
6
  require "async/http/client"
7
7
  require "protocol/http/headers"
@@ -11,13 +11,18 @@ require "console/event/failure"
11
11
  require "traces/provider"
12
12
 
13
13
  module Falcon
14
+ # @namespace
14
15
  module Middleware
15
16
  # A static middleware which always returns a 400 bad request response.
16
17
  module BadRequest
18
+ # Handle a request by returning a 400 bad request response.
19
+ # @parameter request [Protocol::HTTP::Request] The incoming request.
20
+ # @returns [Protocol::HTTP::Response] A 400 bad request response.
17
21
  def self.call(request)
18
22
  return Protocol::HTTP::Response[400, {}, []]
19
23
  end
20
24
 
25
+ # Close any resources used by this middleware.
21
26
  def self.close
22
27
  end
23
28
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2025, by Samuel Williams.
4
+ # Copyright, 2018-2026, by Samuel Williams.
5
5
 
6
6
  require "async/http/client"
7
7
 
@@ -9,10 +9,14 @@ module Falcon
9
9
  module Middleware
10
10
  # A static middleware which always returns a 404 not found response.
11
11
  module NotFound
12
+ # Handle a request by returning a 404 not found response.
13
+ # @parameter request [Protocol::HTTP::Request] The incoming request.
14
+ # @returns [Protocol::HTTP::Response] A 404 not found response.
12
15
  def self.call(request)
13
16
  return Protocol::HTTP::Response[404, {}, []]
14
17
  end
15
18
 
19
+ # Close any resources used by this middleware.
16
20
  def self.close
17
21
  end
18
22
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
 
6
6
  require "io/endpoint/unix_endpoint"
7
7
 
@@ -16,6 +16,8 @@ module Falcon
16
16
  @endpoint = endpoint
17
17
  end
18
18
 
19
+ # Generate a string representation of the proxy endpoint.
20
+ # @returns [String] A string representation including protocol and endpoint.
19
21
  def to_s
20
22
  "\#<#{self.class} protocol=#{self.protocol} endpoint=#{@endpoint}>"
21
23
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024-2025, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "../../falcon"
7
7
 
@@ -9,6 +9,7 @@ require "kernel/sync"
9
9
  require "io/endpoint/host_endpoint"
10
10
 
11
11
  module Falcon
12
+ # @namespace
12
13
  module Rackup
13
14
  # The falcon adaptor for the `rackup` executable.
14
15
  class Handler
@@ -51,6 +52,9 @@ module Falcon
51
52
  end
52
53
  end
53
54
 
55
+ # Initialize the handler with a server and task.
56
+ # @parameter server [Falcon::Server] The server instance.
57
+ # @parameter task [Async::Task] The async task managing the server.
54
58
  def initialize(server, task)
55
59
  @server = server
56
60
  @task = task
@@ -65,10 +69,12 @@ module Falcon
65
69
  end
66
70
  end
67
71
 
72
+ # Signal the handler to stop the server.
68
73
  def stop
69
74
  @notification&.push(true)
70
75
  end
71
76
 
77
+ # Close the handler and clean up resources.
72
78
  def close
73
79
  @notification&.close
74
80
  @notification = nil
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  module Falcon
7
+ # Rails integration for Falcon, configuring ActiveSupport to use fiber-based isolation.
7
8
  class Railtie < Rails::Railtie
8
9
  config.active_support.isolation_level = :fiber
9
10
  end
data/lib/falcon/server.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2025, by Samuel Williams.
4
+ # Copyright, 2017-2026, by Samuel Williams.
5
5
 
6
6
  require "async/http/server"
7
7
 
@@ -9,6 +9,8 @@ require "protocol/http/middleware/builder"
9
9
  require "protocol/http/content_encoding"
10
10
 
11
11
  require "async/http/cache"
12
+ require "async/utilization"
13
+ require_relative "body/request_finished"
12
14
  require_relative "middleware/verbose"
13
15
  require "protocol/rack"
14
16
 
@@ -36,36 +38,41 @@ module Falcon
36
38
  end
37
39
  end
38
40
 
39
- def initialize(...)
40
- super
41
+ # Initialize the server and set up statistics tracking.
42
+ #
43
+ # @parameter utilization_registry [Registry, nil] The utilization registry to use for metrics tracking.
44
+ # If nil, a new registry instance is created.
45
+ def initialize(*arguments, utilization_registry: nil, **options)
46
+ super(*arguments, **options)
41
47
 
42
- @accept_count = 0
43
- @connection_count = 0
48
+ utilization_registry ||= Async::Utilization::Registry.new
44
49
 
45
- @request_count = 0
46
- @active_count = 0
50
+ # Get metric references for utilization tracking:
51
+ @connections_total_metric = utilization_registry.metric(:connections_total)
52
+ @connections_active_metric = utilization_registry.metric(:connections_active)
53
+ @requests_total_metric = utilization_registry.metric(:requests_total)
54
+ @requests_active_metric = utilization_registry.metric(:requests_active)
47
55
  end
48
56
 
49
- attr :request_count
50
- attr :accept_count
51
- attr :connect_count
52
-
57
+ # Accept a new connection and track connection statistics.
53
58
  def accept(...)
54
- @accept_count += 1
55
- @connection_count += 1
56
-
57
- super
58
- ensure
59
- @connection_count -= 1
59
+ @connections_total_metric.increment
60
+ @connections_active_metric.track do
61
+ super
62
+ end
60
63
  end
61
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.
62
71
  def call(...)
63
- @request_count += 1
64
- @active_count += 1
72
+ @requests_total_metric.increment
73
+ @requests_active_metric.increment
65
74
 
66
- super
67
- ensure
68
- @active_count -= 1
75
+ return Body::RequestFinished.wrap(super, @requests_active_metric)
69
76
  end
70
77
 
71
78
  # Generates a human-readable string representing the current statistics.
@@ -80,7 +87,7 @@ module Falcon
80
87
  #
81
88
  # @returns [String] A string representing the current statistics.
82
89
  def statistics_string
83
- "C=#{format_count @connection_count}/#{format_count @accept_count} R=#{format_count @active_count}/#{format_count @request_count}"
90
+ "C=#{format_count @connections_active_metric.value}/#{format_count @connections_total_metric.value} R=#{format_count @requests_active_metric.value}/#{format_count @requests_total_metric.value}"
84
91
  end
85
92
 
86
93
  private
@@ -1,18 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
  # Copyright, 2020, by Daniel Evans.
6
6
 
7
7
  require "async/service/managed/service"
8
- require "async/container/supervisor/supervised"
8
+ require "async/service/supervisor/supervised"
9
9
  require "async/http/endpoint"
10
10
 
11
11
  require_relative "../server"
12
12
 
13
13
  module Falcon
14
+ # @namespace
14
15
  module Service
16
+ # A managed service for running Falcon servers.
15
17
  class Server < Async::Service::Managed::Service
18
+ # Initialize the server service.
16
19
  def initialize(...)
17
20
  super
18
21
 
@@ -27,7 +30,7 @@ module Falcon
27
30
  @bound_endpoint = @endpoint.bound
28
31
  end
29
32
 
30
- Console.logger.info(self) {"Starting #{self.name} on #{@endpoint}"}
33
+ Console.info(self){"Starting #{self.name} on #{@endpoint}"}
31
34
 
32
35
  super
33
36
  end
data/lib/falcon/tls.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2023, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  module Falcon
7
+ # TLS configuration and cipher suites for Falcon servers.
7
8
  module TLS
8
9
  # The list of supported ciphers.
9
10
  #
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2025, by Samuel Williams.
4
+ # Copyright, 2017-2026, by Samuel Williams.
5
5
 
6
+ # @namespace
6
7
  module Falcon
7
- VERSION = "0.54.3"
8
+ VERSION = "0.55.1"
8
9
  end
data/lib/falcon.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2024, by Samuel Williams.
4
+ # Copyright, 2017-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "falcon/version"
7
7
  require_relative "falcon/server"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2025, by Samuel Williams.
4
+ # Copyright, 2017-2026, by Samuel Williams.
5
5
  # Copyright, 2019, by Bryan Powell.
6
6
 
7
7
  require "rack/handler"
@@ -10,7 +10,9 @@ require_relative "../../falcon/rackup/handler"
10
10
 
11
11
  # Generally speaking, you should not require this file directly, or assume the existance of the `Rack::Handler::Falcon` constant. Instead, use `Rack::Handler.get(:falcon)` to load and access the handler.
12
12
 
13
+ # @namespace
13
14
  module Rack
15
+ # @namespace
14
16
  module Handler
15
17
  # Rack (v2) expects the constant to be in the `Rack::Handler` namespace, so we define a new handler class in the `Rack::Handler` namespace that inherits from `Falcon::Rackup::Handler`.
16
18
  class Falcon < ::Falcon::Rackup::Handler
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023-2025, by Samuel Williams.
4
+ # Copyright, 2023-2026, by Samuel Williams.
5
5
 
6
6
  require "rackup/handler"
7
7
 
@@ -9,7 +9,9 @@ require_relative "../../falcon/rackup/handler"
9
9
 
10
10
  # Generally speaking, you should not require this file directly, or assume the existance of the `Rackup::Handler::Falcon` constant. Instead, use `Rackup::Handler.get(:falcon)` to load and access the handler.
11
11
 
12
+ # @namespace
12
13
  module Rackup
14
+ # @namespace
13
15
  module Handler
14
16
  # Sinatra (and possibly others) try to extract the name using the final part of the class path, so we define a new class in the `Rack::Handler` namespace that inherits from `Falcon::Rackup::Handler`, that follows that convention.
15
17
  class Falcon < ::Falcon::Rackup::Handler
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2017-2025, by Samuel Williams.
3
+ Copyright, 2017-2026, by Samuel Williams.
4
4
  Copyright, 2018, by Kent Gruber.
5
5
  Copyright, 2018, by Janko Marohnić.
6
6
  Copyright, 2018, by Tad Thorley.
data/readme.md CHANGED
@@ -47,6 +47,17 @@ 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
+
54
+ ### v0.55.0
55
+
56
+ - **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
57
+ - **Breaking**: Remove support for legacy environments, including `Falcon::Configuration`, now using `Async::Service::Configuration` directly.
58
+ - **Breaking**: `bake falcon:supervisor:restart` removed – superceeded by `async:service:supervisor:restart`.
59
+ - Add support for `async-utilization` metrics.
60
+
50
61
  ### v0.54.1
51
62
 
52
63
  - Fix handling of old style supervisors from `Async::Container::Supervisor`.
@@ -85,16 +96,6 @@ Please see the [project releases](https://socketry.github.io/falcon/releases/ind
85
96
 
86
97
  - Improve compatibility of rackup handler w.r.t. sinatra.
87
98
 
88
- ### v0.47.8
89
-
90
- - Fix Falcon Supervisor implementation: due to invalid code, it was unable to start.
91
-
92
- ### Compatibility Fixes
93
-
94
- During the `v0.44.0` release cycle, the workflows for testing older rack releases were accidentally dropped. As such, `v0.44.0` was not compatible with older versions of rack. This release restores compatibility with older versions of rack.
95
-
96
- Specifically, `protocol-rack` now provides `Protocol::Rack::Adapter.parse_file` to load Rack applications. Rack 2's `Rack::Builder.parse_file` returns both the application and a set of options (multi-value return). Rack 3 changed this to only return the application, as the prior multi-value return was confusing at best. This change allows `protocol-rack` to work with both versions of rack, and `falcon` adopts that interface.
97
-
98
99
  ## Contributing
99
100
 
100
101
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,16 @@
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
+
7
+ ## v0.55.0
8
+
9
+ - **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
10
+ - **Breaking**: Remove support for legacy environments, including `Falcon::Configuration`, now using `Async::Service::Configuration` directly.
11
+ - **Breaking**: `bake falcon:supervisor:restart` removed – superceeded by `async:service:supervisor:restart`.
12
+ - Add support for `async-utilization` metrics.
13
+
3
14
  ## v0.54.1
4
15
 
5
16
  - Fix handling of old style supervisors from `Async::Container::Supervisor`.
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.54.3
4
+ version: 0.55.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -94,61 +94,61 @@ dependencies:
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0.20'
96
96
  - !ruby/object:Gem::Dependency
97
- name: async-container-supervisor
97
+ name: async-http
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0.6'
102
+ version: '0.75'
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '0.6'
109
+ version: '0.75'
110
110
  - !ruby/object:Gem::Dependency
111
- name: async-http
111
+ name: async-http-cache
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '0.75'
116
+ version: '0.4'
117
117
  type: :runtime
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '0.75'
123
+ version: '0.4'
124
124
  - !ruby/object:Gem::Dependency
125
- name: async-http-cache
125
+ name: async-service
126
126
  requirement: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '0.4'
130
+ version: '0.19'
131
131
  type: :runtime
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '0.4'
137
+ version: '0.19'
138
138
  - !ruby/object:Gem::Dependency
139
- name: async-service
139
+ name: async-utilization
140
140
  requirement: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '0.19'
144
+ version: '0.3'
145
145
  type: :runtime
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: '0.19'
151
+ version: '0.3'
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: bundler
154
154
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +239,6 @@ executables:
239
239
  extensions: []
240
240
  extra_rdoc_files: []
241
241
  files:
242
- - bake/falcon/supervisor.rb
243
242
  - bin/falcon
244
243
  - bin/falcon-host
245
244
  - context/deployment.md
@@ -253,6 +252,7 @@ files:
253
252
  - context/rails-integration.md
254
253
  - context/websockets.md
255
254
  - lib/falcon.rb
255
+ - lib/falcon/body/request_finished.rb
256
256
  - lib/falcon/command.rb
257
257
  - lib/falcon/command/host.rb
258
258
  - lib/falcon/command/paths.rb
@@ -262,7 +262,6 @@ files:
262
262
  - lib/falcon/command/top.rb
263
263
  - lib/falcon/command/virtual.rb
264
264
  - lib/falcon/composite_server.rb
265
- - lib/falcon/configuration.rb
266
265
  - lib/falcon/endpoint.rb
267
266
  - lib/falcon/environment.rb
268
267
  - lib/falcon/environment/application.rb
@@ -274,7 +273,6 @@ files:
274
273
  - lib/falcon/environment/redirect.rb
275
274
  - lib/falcon/environment/self_signed_tls.rb
276
275
  - lib/falcon/environment/server.rb
277
- - lib/falcon/environment/supervisor.rb
278
276
  - lib/falcon/environment/tls.rb
279
277
  - lib/falcon/environment/virtual.rb
280
278
  - lib/falcon/middleware/proxy.rb
@@ -306,7 +304,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
304
  requirements:
307
305
  - - ">="
308
306
  - !ruby/object:Gem::Version
309
- version: '3.2'
307
+ version: '3.3'
310
308
  required_rubygems_version: !ruby/object:Gem::Requirement
311
309
  requirements:
312
310
  - - ">="
metadata.gz.sig CHANGED
Binary file
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
5
-
6
- def restart
7
- context.lookup("async:container:supervisor:restart").call
8
- end
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
5
- # Copyright, 2019, by Sho Ito.
6
-
7
- require "async/service"
8
-
9
- module Falcon
10
- # Manages environments which describes how to host a specific application.
11
- #
12
- # Environments are key-value maps with lazy value resolution. An environment can inherit from a parent environment, which can provide defaults or shared configuration.
13
- #
14
- class Configuration < ::Async::Service::Configuration
15
- # Load the specified configuration file. See {Loader#load_file} for more details.
16
- def load_file(path)
17
- Loader.load_file(self, path)
18
- end
19
-
20
- # The domain specific language for loading configuration files.
21
- class Loader < ::Async::Service::Loader
22
- # Load specific features into the current configuration.
23
- #
24
- # @deprecated Use `require` instead.
25
- # @parameter features [Array(Symbol)] The features to load.
26
- def load(*features)
27
- features.each do |feature|
28
- case feature
29
- when Symbol
30
- require File.join(__dir__, "environment", "#{feature}.rb")
31
- else
32
- raise LoadError, "Unsure about how to load #{feature}!"
33
- end
34
- end
35
- end
36
-
37
- # Define a host with the specified name.
38
- # Adds `root` and `authority` keys.
39
- # @deprecated Use `service` and `include Falcon::Environment::Server` instead.
40
- # @parameter name [String] The name of the environment, usually a hostname.
41
- def host(name, *parents, &block)
42
- @configuration.add(
43
- merge(*parents, name: name, root: @root, authority: name, &block)
44
- )
45
- end
46
-
47
- # Define a proxy with the specified name.
48
- # Adds `root` and `authority` keys.
49
- # @deprecated Use `service` and `include Falcon::Environment::Proxy` instead.
50
- # @parameter name [String] The name of the environment, usually a hostname.
51
- def proxy(name, *parents, &block)
52
- @configuration.add(
53
- merge(:proxy, *parents, name: name, root: @root, authority: name, &block)
54
- )
55
- end
56
-
57
- # Define a rack application with the specified name.
58
- # Adds `root` and `authority` keys.
59
- # @deprecated Use `service` and `include Falcon::Environment::Rack` instead.
60
- # @parameter name [String] The name of the environment, usually a hostname.
61
- def rack(name, *parents, &block)
62
- @configuration.add(
63
- merge(:rack, *parents, name: name, root: @root, authority: name, &block)
64
- )
65
- end
66
-
67
- # Define a supervisor instance
68
- # @deprecated Use `service` and `include Falcon::Environment::Supervisor` instead.
69
- def supervisor(&block)
70
- name = File.join(@root, "supervisor")
71
-
72
- @configuration.add(
73
- merge(:supervisor, name: name, root: @root, &block)
74
- )
75
- end
76
-
77
- private
78
-
79
- # Build a new environment with the specified name and the given parents.
80
- # @parameter name [String]
81
- # @parameter parents [Array(Symbol)]
82
- # @yields {...} The block that will generate the environment.
83
- def merge(*parents, **initial, &block)
84
- facets = parents.map{|parent| Environment::LEGACY_ENVIRONMENTS.fetch(parent)}
85
-
86
- ::Async::Service::Environment.build(*facets, **initial, &block)
87
- end
88
- end
89
- end
90
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
5
-
6
- require_relative "../environment"
7
-
8
- require "async/container/supervisor"
9
-
10
- module Falcon
11
- module Environment
12
- # Provides an environment for hosting a supervisor which can monitor multiple applications.
13
- module Supervisor
14
- include Async::Container::Supervisor::Environment
15
-
16
- def monitors
17
- [Async::Container::Supervisor::MemoryMonitor.new(interval: 10)]
18
- end
19
- end
20
-
21
- LEGACY_ENVIRONMENTS[:supervisor] = Supervisor
22
- end
23
- end