falcon 0.54.3 → 0.55.0

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 (44) 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/command/host.rb +2 -2
  5. data/lib/falcon/command/paths.rb +3 -3
  6. data/lib/falcon/command/proxy.rb +8 -3
  7. data/lib/falcon/command/redirect.rb +11 -3
  8. data/lib/falcon/command/serve.rb +14 -4
  9. data/lib/falcon/command/top.rb +2 -2
  10. data/lib/falcon/command/virtual.rb +6 -2
  11. data/lib/falcon/command.rb +2 -1
  12. data/lib/falcon/composite_server.rb +1 -1
  13. data/lib/falcon/environment/configured.rb +4 -2
  14. data/lib/falcon/environment/lets_encrypt_tls.rb +1 -3
  15. data/lib/falcon/environment/proxy.rb +6 -11
  16. data/lib/falcon/environment/rack.rb +1 -3
  17. data/lib/falcon/environment/rackup.rb +7 -1
  18. data/lib/falcon/environment/redirect.rb +8 -2
  19. data/lib/falcon/environment/self_signed_tls.rb +1 -3
  20. data/lib/falcon/environment/server.rb +2 -2
  21. data/lib/falcon/environment/tls.rb +1 -2
  22. data/lib/falcon/environment/virtual.rb +4 -1
  23. data/lib/falcon/environment.rb +1 -4
  24. data/lib/falcon/middleware/proxy.rb +6 -1
  25. data/lib/falcon/middleware/redirect.rb +5 -1
  26. data/lib/falcon/proxy_endpoint.rb +3 -1
  27. data/lib/falcon/rackup/handler.rb +7 -1
  28. data/lib/falcon/railtie.rb +2 -1
  29. data/lib/falcon/server.rb +25 -24
  30. data/lib/falcon/service/server.rb +6 -3
  31. data/lib/falcon/tls.rb +2 -1
  32. data/lib/falcon/version.rb +3 -2
  33. data/lib/falcon.rb +1 -1
  34. data/lib/rack/handler/falcon.rb +3 -1
  35. data/lib/rackup/handler/falcon.rb +3 -1
  36. data/license.md +1 -1
  37. data/readme.md +7 -6
  38. data/releases.md +7 -0
  39. data.tar.gz.sig +0 -0
  40. metadata +14 -17
  41. metadata.gz.sig +0 -0
  42. data/bake/falcon/supervisor.rb +0 -8
  43. data/lib/falcon/configuration.rb +0 -90
  44. data/lib/falcon/environment/supervisor.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22b09155428d4918e4f5b81cc0b809a8ca678f2509fbfb42f7e67cb2621d74dc
4
- data.tar.gz: df9bbb12499685689dd38a38ede8807f5f09022394c13386766a178bc0760962
3
+ metadata.gz: 8aa8fb7fb61e5c4112b6e7e3423a59e27a0f00555edd04ab381ca58f064b10cd
4
+ data.tar.gz: a8a3a69df547475b9fd306f0bedd3e0f4836f1d3f42be43f1f6b1d53746b82e5
5
5
  SHA512:
6
- metadata.gz: 8a483823b106bf170b158c70f797e3cbb1a233fc74b7be20d7deed8d8d0b690b1f5945330a64b9c5245978759f91fee7b14b1dbf35ede89021a0c6e902a652f2
7
- data.tar.gz: 4707fbfbbe508fa06e32815c6ed5e0ba3d6ebc279af9f1460a9be633e86aecc8a05b49919f885ff848c50cd3bc2d8b058671622c44b7b95ee4119c91f1746155
6
+ metadata.gz: 2dca19722a68b6bd56f1caf3639cc5b4f952a6d908a5e2e36f10cf1e6a3e733d1d423c1713dab0ac8dc5e1adc595d2d6acb345a24d868c85e1b6ca706164fd00
7
+ data.tar.gz: 6d1ffeb9711b90027841489a348322fe955004cab78a2aa5a26a6ec61be6613013dc33d87b675776338b91aa2715cf3423959e05947e8e3ff42e886e50727666
checksums.yaml.gz.sig CHANGED
Binary file
@@ -24,7 +24,7 @@ Here is a basic example which hosts a rack application:
24
24
 
25
25
  require "falcon/environment/rack"
26
26
  require "falcon/environment/lets_encrypt_tls"
27
- require "falcon/environment/supervisor"
27
+ require "async/service/supervisor"
28
28
 
29
29
  hostname = File.basename(__dir__)
30
30
  service hostname do
@@ -35,11 +35,11 @@ service hostname do
35
35
  cache true
36
36
 
37
37
  # Connect to the supervisor for monitoring.
38
- include Async::Container::Supervisor::Supervised
38
+ include Async::Service::Supervisor::Supervised
39
39
  end
40
40
 
41
41
  service "supervisor" do
42
- include Falcon::Environment::Supervisor
42
+ include Async::Service::Supervisor::Environment
43
43
 
44
44
  monitors do
45
45
  [
@@ -71,7 +71,7 @@ The environment configuration is defined in the `Falcon::Environment` module. Th
71
71
  # frozen_string_literal: true
72
72
 
73
73
  require "falcon/environment/rack"
74
- require "falcon/environment/supervisor"
74
+ require "async/service/supervisor"
75
75
 
76
76
  hostname = File.basename(__dir__)
77
77
  service hostname do
@@ -86,7 +86,7 @@ service hostname do
86
86
  end
87
87
 
88
88
  service "supervisor" do
89
- include Falcon::Environment::Supervisor
89
+ include Async::Service::Supervisor::Environment
90
90
  end
91
91
  ~~~
92
92
 
@@ -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_relative "paths"
7
7
  require_relative "../version"
@@ -31,7 +31,7 @@ module Falcon
31
31
 
32
32
  # Prepare the environment and run the controller.
33
33
  def call
34
- Console.logger.info(self) do |buffer|
34
+ Console.info(self) do |buffer|
35
35
  buffer.puts "Falcon Host v#{VERSION} taking flight!"
36
36
  buffer.puts "- Configuration: #{@paths.join(', ')}"
37
37
  buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
- require_relative "../configuration"
6
+ require "async/service/configuration"
7
7
 
8
8
  module Falcon
9
9
  module Command
@@ -21,7 +21,7 @@ module Falcon
21
21
 
22
22
  # Build a configuration based on the resolved paths.
23
23
  def configuration
24
- configuration = Configuration.new
24
+ configuration = Async::Service::Configuration.new
25
25
 
26
26
  self.resolved_paths do |path|
27
27
  path = File.expand_path(path)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "../environment/proxy"
7
7
  require_relative "paths"
@@ -31,6 +31,9 @@ module Falcon
31
31
 
32
32
  include Paths
33
33
 
34
+ # Create the environment for the proxy service.
35
+ # @parameter options [Hash] Additional options to pass to the environment.
36
+ # @returns [Async::Service::Environment] The configured proxy environment.
34
37
  def environment(**options)
35
38
  Async::Service::Environment.new(Falcon::Environment::Proxy).with(
36
39
  root: Dir.pwd,
@@ -42,15 +45,17 @@ module Falcon
42
45
  )
43
46
  end
44
47
 
48
+ # Build the service configuration for the proxy.
49
+ # @returns [Async::Service::Configuration] The service configuration.
45
50
  def configuration
46
- Configuration.for(
51
+ Async::Service::Configuration.for(
47
52
  self.environment(environments: super.environments)
48
53
  )
49
54
  end
50
55
 
51
56
  # Prepare the environment and run the controller.
52
57
  def call
53
- Console.logger.info(self) do |buffer|
58
+ Console.info(self) do |buffer|
54
59
  buffer.puts "Falcon Proxy v#{VERSION} taking flight!"
55
60
  buffer.puts "- Binding to: #{@options[:bind]}"
56
61
  buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "../environment/redirect"
7
7
  require_relative "paths"
@@ -10,6 +10,9 @@ require "samovar"
10
10
 
11
11
  module Falcon
12
12
  module Command
13
+ # Implements the `falcon redirect` command.
14
+ #
15
+ # Manages a {Controller::Redirect} instance which redirects insecure HTTP traffic to secure HTTPS endpoints.
13
16
  class Redirect < Samovar::Command
14
17
  self.description = "Redirect from insecure HTTP to secure HTTP."
15
18
 
@@ -29,6 +32,9 @@ module Falcon
29
32
 
30
33
  include Paths
31
34
 
35
+ # Create the environment for the redirect service.
36
+ # @parameter options [Hash] Additional options to pass to the environment.
37
+ # @returns [Async::Service::Environment] The configured redirect environment.
32
38
  def environment(**options)
33
39
  Async::Service::Environment.new(Falcon::Environment::Redirect).with(
34
40
  root: Dir.pwd,
@@ -41,15 +47,17 @@ module Falcon
41
47
  )
42
48
  end
43
49
 
50
+ # Build the service configuration for the redirect.
51
+ # @returns [Async::Service::Configuration] The service configuration.
44
52
  def configuration
45
- Configuration.for(
53
+ Async::Service::Configuration.for(
46
54
  self.environment(environments: super.environments)
47
55
  )
48
56
  end
49
57
 
50
58
  # Prepare the environment and run the controller.
51
59
  def call
52
- Console.logger.info(self) do |buffer|
60
+ Console.info(self) do |buffer|
53
61
  buffer.puts "Falcon Redirect v#{VERSION} taking flight!"
54
62
  buffer.puts "- Binding to: #{@options[:bind]}"
55
63
  buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
@@ -1,15 +1,15 @@
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
  # Copyright, 2018, by Mitsutaka Mimura.
6
6
 
7
7
  require_relative "../server"
8
8
  require_relative "../endpoint"
9
- require_relative "../configuration"
10
9
  require_relative "../service/server"
11
10
  require_relative "../environment/rackup"
12
11
 
12
+ require "async/service/configuration"
13
13
  require "async/container"
14
14
  require "async/http/client"
15
15
  require "samovar"
@@ -49,18 +49,26 @@ module Falcon
49
49
  option "--health-check-timeout <duration>", "Duration to wait for health check.", type: Float, default: 30.0
50
50
  end
51
51
 
52
+ # Extract container-related options from the command line options.
53
+ # @returns [Hash] Options for container configuration.
52
54
  def container_options
53
55
  @options.slice(:count, :forks, :threads, :restart, :health_check_timeout)
54
56
  end
55
57
 
58
+ # Extract endpoint-related options from the command line options.
59
+ # @returns [Hash] Options for endpoint configuration.
56
60
  def endpoint_options
57
61
  @options.slice(:hostname, :port, :timeout)
58
62
  end
59
63
 
64
+ # Get the name for the service, using hostname if available, otherwise the bind address.
65
+ # @returns [String] The service name.
60
66
  def name
61
67
  @options[:hostname] || @options[:bind]
62
68
  end
63
69
 
70
+ # Create the environment for the serve command.
71
+ # @returns [Async::Service::Environment] The configured server environment.
64
72
  def environment
65
73
  Async::Service::Environment.new(Falcon::Environment::Server).with(
66
74
  Falcon::Environment::Rackup,
@@ -82,8 +90,10 @@ module Falcon
82
90
  )
83
91
  end
84
92
 
93
+ # Build the service configuration for the serve command.
94
+ # @returns [Async::Service::Configuration] The service configuration.
85
95
  def configuration
86
- Configuration.new.tap do |configuration|
96
+ Async::Service::Configuration.new.tap do |configuration|
87
97
  configuration.add(self.environment)
88
98
  end
89
99
  end
@@ -117,7 +127,7 @@ module Falcon
117
127
 
118
128
  # Prepare the environment and run the controller.
119
129
  def call
120
- Console.logger.info(self) do |buffer|
130
+ Console.info(self) do |buffer|
121
131
  buffer.puts "Falcon v#{VERSION} taking flight! Using #{self.container_class} #{self.container_options}."
122
132
  buffer.puts "- Running on #{RUBY_DESCRIPTION}"
123
133
  buffer.puts "- Binding to: #{self.endpoint}"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "serve"
7
7
  require_relative "host"
@@ -58,7 +58,7 @@ module Falcon
58
58
  # @parameter encoding [Encoding] Defaults to `Encoding::UTF_8`.
59
59
  def update_external_encoding!(encoding = Encoding::UTF_8)
60
60
  if Encoding.default_external != encoding
61
- Console.logger.warn(self) {"Updating Encoding.default_external from #{Encoding.default_external} to #{encoding}"}
61
+ Console.warn(self){"Updating Encoding.default_external from #{Encoding.default_external} to #{encoding}"}
62
62
  Encoding.default_external = encoding
63
63
  end
64
64
  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/service"
7
7
 
@@ -31,6 +31,8 @@ module Falcon
31
31
  # @attribute [Array(String)]
32
32
  many :paths
33
33
 
34
+ # Create the environment for the virtual host service.
35
+ # @returns [Async::Service::Environment] The configured virtual environment.
34
36
  def environment
35
37
  Async::Service::Environment.new(Falcon::Environment::Virtual).with(
36
38
  verbose: self.parent&.verbose?,
@@ -41,6 +43,8 @@ module Falcon
41
43
  )
42
44
  end
43
45
 
46
+ # Build the service configuration for the virtual host.
47
+ # @returns [Async::Service::Configuration] The service configuration.
44
48
  def configuration
45
49
  Async::Service::Configuration.new.tap do |configuration|
46
50
  configuration.add(self.environment)
@@ -49,7 +53,7 @@ module Falcon
49
53
 
50
54
  # Prepare the environment and run the controller.
51
55
  def call
52
- Console.logger.info(self) do |buffer|
56
+ Console.info(self) do |buffer|
53
57
  buffer.puts "Falcon Virtual v#{VERSION} taking flight!"
54
58
  buffer.puts "- Running on #{RUBY_DESCRIPTION}"
55
59
  buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
@@ -1,12 +1,13 @@
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, 2018, by Mitsutaka Mimura.
6
6
 
7
7
  require_relative "command/top"
8
8
 
9
9
  module Falcon
10
+ # @namespace
10
11
  module Command
11
12
  # The main entry point for the `falcon` executable.
12
13
  # @parameter arguments [Array(String)] The command line arguments.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2025, by Samuel Williams.
4
+ # Copyright, 2026, by Samuel Williams.
5
5
 
6
6
  require "async"
7
7
 
@@ -1,7 +1,7 @@
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
7
  module Environment
@@ -25,8 +25,10 @@ module Falcon
25
25
  end
26
26
  end
27
27
 
28
+ # Load the configuration from all resolved configuration paths.
29
+ # @returns [Async::Service::Configuration] The loaded configuration.
28
30
  def configuration
29
- ::Async::Service::Configuration.load(resolved_configuration_paths)
31
+ Async::Service::Configuration.load(resolved_configuration_paths)
30
32
  end
31
33
  end
32
34
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "tls"
7
7
  require_relative "../environment"
@@ -28,7 +28,5 @@ module Falcon
28
28
  File.join(lets_encrypt_root, authority, "privkey.pem")
29
29
  end
30
30
  end
31
-
32
- LEGACY_ENVIRONMENTS[:lets_encrypt_tls] = LetsEncryptTLS
33
31
  end
34
32
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "server"
7
7
  require_relative "../tls"
@@ -40,13 +40,8 @@ module Falcon
40
40
 
41
41
  # next unless environment.implements?(Falcon::Environment::Application)
42
42
  if evaluator.key?(:authority) and evaluator.key?(:ssl_context) and evaluator.key?(:endpoint)
43
- Console.info(self) {"Proxying #{self.url} to #{evaluator.authority} using #{evaluator.endpoint}"}
43
+ Console.info(self){"Proxying #{self.url} to #{evaluator.authority} using #{evaluator.endpoint}"}
44
44
  hosts[evaluator.authority] = evaluator
45
-
46
- if RUBY_VERSION < "3.1"
47
- # Ensure the SSL context is set up before forking - it's buggy on Ruby < 3.1:
48
- evaluator.ssl_context
49
- end
50
45
  end
51
46
  end
52
47
 
@@ -60,13 +55,13 @@ module Falcon
60
55
  hosts = self.hosts
61
56
 
62
57
  if host = hosts[hostname]
63
- Console.logger.debug(self) {"Resolving #{hostname} -> #{host}"}
58
+ Console.debug(self){"Resolving #{hostname} -> #{host}"}
64
59
 
65
60
  socket.hostname = hostname
66
61
 
67
62
  return host.ssl_context
68
63
  else
69
- Console.logger.warn(self, hosts: hosts.keys) {"Unable to resolve #{hostname}!"}
64
+ Console.warn(self, hosts: hosts.keys){"Unable to resolve #{hostname}!"}
70
65
 
71
66
  return nil
72
67
  end
@@ -97,11 +92,11 @@ module Falcon
97
92
  )
98
93
  end
99
94
 
95
+ # Build the proxy middleware with the configured hosts.
96
+ # @returns [Middleware::Proxy] The proxy middleware instance.
100
97
  def middleware
101
98
  return Middleware::Proxy.new(Middleware::BadRequest, self.hosts)
102
99
  end
103
100
  end
104
-
105
- LEGACY_ENVIRONMENTS[:proxy] = Proxy
106
101
  end
107
102
  end
@@ -1,7 +1,7 @@
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
  require_relative "application"
7
7
  require_relative "rackup"
@@ -14,7 +14,5 @@ module Falcon
14
14
  include Application
15
15
  include Rackup
16
16
  end
17
-
18
- LEGACY_ENVIRONMENTS[:rack] = Rack
19
17
  end
20
18
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require "rack/builder"
7
7
  require_relative "../server"
@@ -10,14 +10,20 @@ module Falcon
10
10
  module Environment
11
11
  # Provides an environment for hosting loading a Rackup `config.ru` file.
12
12
  module Rackup
13
+ # The path to the rackup configuration file.
14
+ # @returns [String] The absolute path to the rackup file.
13
15
  def rackup_path
14
16
  File.expand_path("config.ru", root)
15
17
  end
16
18
 
19
+ # Parse and load the rack application from the rackup file.
20
+ # @returns [Protocol::Rack::Adapter] The parsed rack application.
17
21
  def rack_app
18
22
  ::Protocol::Rack::Adapter.parse_file(rackup_path)
19
23
  end
20
24
 
25
+ # Build the middleware stack for the rack application.
26
+ # @returns [Protocol::HTTP::Middleware] The middleware stack.
21
27
  def middleware
22
28
  ::Falcon::Server.middleware(rack_app, verbose: verbose, cache: cache)
23
29
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "server"
7
7
  require_relative "application"
@@ -13,10 +13,14 @@ module Falcon
13
13
  module Redirect
14
14
  include Server
15
15
 
16
+ # The URL template to redirect to.
17
+ # @returns [String] The redirect URL template.
16
18
  def redirect_url
17
19
  "https://[::]:443"
18
20
  end
19
21
 
22
+ # Parse the redirect URL into an endpoint.
23
+ # @returns [Async::HTTP::Endpoint] The redirect endpoint.
20
24
  def redirect_endpoint
21
25
  Async::HTTP::Endpoint.parse(redirect_url)
22
26
  end
@@ -27,6 +31,8 @@ module Falcon
27
31
  []
28
32
  end
29
33
 
34
+ # Build a hash of host authorities to their evaluators for redirect matching.
35
+ # @returns [Hash(String, Async::Service::Environment::Evaluator)] Map of host authorities to evaluators.
30
36
  def hosts
31
37
  hosts = {}
32
38
 
@@ -34,7 +40,7 @@ module Falcon
34
40
  evaluator = environment.evaluator
35
41
 
36
42
  if environment.implements?(Falcon::Environment::Application)
37
- Console.info(self) {"Redirecting #{self.url} to #{evaluator.authority}"}
43
+ Console.info(self){"Redirecting #{self.url} to #{evaluator.authority}"}
38
44
  hosts[evaluator.authority] = evaluator
39
45
  end
40
46
  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 "localhost/authority"
7
7
  require_relative "tls"
@@ -39,7 +39,5 @@ module Falcon
39
39
  end
40
40
  end
41
41
  end
42
-
43
- LEGACY_ENVIRONMENTS[:self_signed_tls] = SelfSignedTLS
44
42
  end
45
43
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  require "async/service/managed/environment"
7
7
  require "async/http/endpoint"
@@ -72,7 +72,7 @@ module Falcon
72
72
  # @parameter endpoint [IO::Endpoint] The endpoint to bind to.
73
73
  # @returns [Falcon::Server] The server instance.
74
74
  def make_server(endpoint)
75
- Falcon::Server.new(self.middleware, endpoint, protocol: self.endpoint.protocol, scheme: self.endpoint.scheme)
75
+ Falcon::Server.new(self.middleware, endpoint, protocol: self.endpoint.protocol, scheme: self.endpoint.scheme, utilization_registry: self[:utilization_registry])
76
76
  end
77
77
  end
78
78
  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_relative "../tls"
7
7
  require_relative "../environment"
@@ -92,6 +92,5 @@ module Falcon
92
92
  end
93
93
  end
94
94
 
95
- LEGACY_ENVIRONMENTS[:tls] = TLS
96
95
  end
97
96
  end
@@ -1,7 +1,7 @@
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
  require_relative "configured"
7
7
 
@@ -9,6 +9,7 @@ require_relative "../service/virtual"
9
9
 
10
10
  module Falcon
11
11
  module Environment
12
+ # Provides an environment for running virtual hosts with front-end proxy and redirect services.
12
13
  module Virtual
13
14
  include Configured
14
15
 
@@ -18,6 +19,8 @@ module Falcon
18
19
  Service::Virtual
19
20
  end
20
21
 
22
+ # The name of the virtual host service.
23
+ # @returns [String] The service class name.
21
24
  def name
22
25
  service_class.name
23
26
  end
@@ -1,13 +1,10 @@
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
  module Falcon
7
7
  # Pre-defined environments for hosting web applications.
8
- #
9
- # See {Configuration::Loader#load} for more details.
10
8
  module Environment
11
- LEGACY_ENVIRONMENTS = {}
12
9
  end
13
10
  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
  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,7 @@ require "protocol/http/middleware/builder"
9
9
  require "protocol/http/content_encoding"
10
10
 
11
11
  require "async/http/cache"
12
+ require "async/utilization"
12
13
  require_relative "middleware/verbose"
13
14
  require "protocol/rack"
14
15
 
@@ -36,36 +37,36 @@ module Falcon
36
37
  end
37
38
  end
38
39
 
39
- def initialize(...)
40
- super
40
+ # Initialize the server and set up statistics tracking.
41
+ #
42
+ # @parameter utilization_registry [Registry, nil] The utilization registry to use for metrics tracking.
43
+ # If nil, a new registry instance is created.
44
+ def initialize(*arguments, utilization_registry: nil, **options)
45
+ super(*arguments, **options)
41
46
 
42
- @accept_count = 0
43
- @connection_count = 0
47
+ utilization_registry ||= Async::Utilization::Registry.new
44
48
 
45
- @request_count = 0
46
- @active_count = 0
49
+ # Get metric references for utilization tracking:
50
+ @connections_total_metric = utilization_registry.metric(:connections_total)
51
+ @connections_active_metric = utilization_registry.metric(:connections_active)
52
+ @requests_total_metric = utilization_registry.metric(:requests_total)
53
+ @requests_active_metric = utilization_registry.metric(:requests_active)
47
54
  end
48
55
 
49
- attr :request_count
50
- attr :accept_count
51
- attr :connect_count
52
-
56
+ # Accept a new connection and track connection statistics.
53
57
  def accept(...)
54
- @accept_count += 1
55
- @connection_count += 1
56
-
57
- super
58
- ensure
59
- @connection_count -= 1
58
+ @connections_total_metric.increment
59
+ @connections_active_metric.track do
60
+ super
61
+ end
60
62
  end
61
63
 
64
+ # Handle a request and track request statistics.
62
65
  def call(...)
63
- @request_count += 1
64
- @active_count += 1
65
-
66
- super
67
- ensure
68
- @active_count -= 1
66
+ @requests_total_metric.increment
67
+ @requests_active_metric.track do
68
+ super
69
+ end
69
70
  end
70
71
 
71
72
  # Generates a human-readable string representing the current statistics.
@@ -80,7 +81,7 @@ module Falcon
80
81
  #
81
82
  # @returns [String] A string representing the current statistics.
82
83
  def statistics_string
83
- "C=#{format_count @connection_count}/#{format_count @accept_count} R=#{format_count @active_count}/#{format_count @request_count}"
84
+ "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
85
  end
85
86
 
86
87
  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.0"
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,13 @@ 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.0
51
+
52
+ - **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
53
+ - **Breaking**: Remove support for legacy environments, including `Falcon::Configuration`, now using `Async::Service::Configuration` directly.
54
+ - **Breaking**: `bake falcon:supervisor:restart` removed – superceeded by `async:service:supervisor:restart`.
55
+ - Add support for `async-utilization` metrics.
56
+
50
57
  ### v0.54.1
51
58
 
52
59
  - Fix handling of old style supervisors from `Async::Container::Supervisor`.
@@ -89,12 +96,6 @@ Please see the [project releases](https://socketry.github.io/falcon/releases/ind
89
96
 
90
97
  - Fix Falcon Supervisor implementation: due to invalid code, it was unable to start.
91
98
 
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,12 @@
1
1
  # Releases
2
2
 
3
+ ## v0.55.0
4
+
5
+ - **Breaking**: Drop dependency on `async-container-supervisor`, you should migrate to `async-service-supervisor` instead.
6
+ - **Breaking**: Remove support for legacy environments, including `Falcon::Configuration`, now using `Async::Service::Configuration` directly.
7
+ - **Breaking**: `bake falcon:supervisor:restart` removed – superceeded by `async:service:supervisor:restart`.
8
+ - Add support for `async-utilization` metrics.
9
+
3
10
  ## v0.54.1
4
11
 
5
12
  - 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.0
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
@@ -262,7 +261,6 @@ files:
262
261
  - lib/falcon/command/top.rb
263
262
  - lib/falcon/command/virtual.rb
264
263
  - lib/falcon/composite_server.rb
265
- - lib/falcon/configuration.rb
266
264
  - lib/falcon/endpoint.rb
267
265
  - lib/falcon/environment.rb
268
266
  - lib/falcon/environment/application.rb
@@ -274,7 +272,6 @@ files:
274
272
  - lib/falcon/environment/redirect.rb
275
273
  - lib/falcon/environment/self_signed_tls.rb
276
274
  - lib/falcon/environment/server.rb
277
- - lib/falcon/environment/supervisor.rb
278
275
  - lib/falcon/environment/tls.rb
279
276
  - lib/falcon/environment/virtual.rb
280
277
  - lib/falcon/middleware/proxy.rb
@@ -306,7 +303,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
303
  requirements:
307
304
  - - ">="
308
305
  - !ruby/object:Gem::Version
309
- version: '3.2'
306
+ version: '3.3'
310
307
  required_rubygems_version: !ruby/object:Gem::Requirement
311
308
  requirements:
312
309
  - - ">="
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