falcon 0.42.3 → 0.44.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 (62) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/bake/falcon/supervisor.rb +3 -1
  4. data/changes.md +22 -0
  5. data/lib/falcon/command/host.rb +7 -50
  6. data/lib/falcon/command/paths.rb +2 -19
  7. data/lib/falcon/command/proxy.rb +21 -33
  8. data/lib/falcon/command/redirect.rb +22 -33
  9. data/lib/falcon/command/serve.rb +44 -82
  10. data/lib/falcon/command/supervisor.rb +2 -19
  11. data/lib/falcon/command/top.rb +2 -19
  12. data/lib/falcon/command/virtual.rb +16 -41
  13. data/lib/falcon/command.rb +3 -19
  14. data/lib/falcon/configuration.rb +28 -142
  15. data/lib/falcon/endpoint.rb +2 -19
  16. data/lib/falcon/environment/application.rb +60 -0
  17. data/lib/falcon/environment/lets_encrypt_tls.rb +34 -0
  18. data/lib/falcon/environment/proxy.rb +109 -0
  19. data/lib/falcon/environment/rack.rb +20 -0
  20. data/lib/falcon/environment/rackup.rb +26 -0
  21. data/lib/falcon/environment/redirect.rb +50 -0
  22. data/lib/falcon/environment/self_signed_tls.rb +45 -0
  23. data/lib/falcon/environment/server.rb +69 -0
  24. data/lib/falcon/environment/supervisor.rb +40 -0
  25. data/lib/falcon/environment/tls.rb +97 -0
  26. data/lib/falcon/environment.rb +13 -0
  27. data/lib/falcon/middleware/proxy.rb +3 -20
  28. data/lib/falcon/middleware/redirect.rb +2 -19
  29. data/lib/falcon/middleware/verbose.rb +2 -19
  30. data/lib/falcon/proxy_endpoint.rb +2 -19
  31. data/lib/falcon/railtie.rb +10 -0
  32. data/lib/falcon/server.rb +2 -19
  33. data/lib/falcon/service/server.rb +84 -0
  34. data/lib/falcon/service/supervisor.rb +5 -21
  35. data/lib/falcon/{controller → service}/virtual.rb +72 -36
  36. data/lib/falcon/tls.rb +2 -19
  37. data/lib/falcon/version.rb +3 -20
  38. data/lib/falcon.rb +5 -19
  39. data/lib/rack/handler/falcon.rb +4 -0
  40. data/lib/rackup/handler/falcon.rb +83 -0
  41. data/license.md +41 -0
  42. data/readme.md +60 -0
  43. data.tar.gz.sig +0 -0
  44. metadata +37 -117
  45. metadata.gz.sig +0 -0
  46. data/lib/.DS_Store +0 -0
  47. data/lib/falcon/controller/host.rb +0 -72
  48. data/lib/falcon/controller/proxy.rb +0 -126
  49. data/lib/falcon/controller/redirect.rb +0 -76
  50. data/lib/falcon/controller/serve.rb +0 -126
  51. data/lib/falcon/environments/application.rb +0 -72
  52. data/lib/falcon/environments/lets_encrypt_tls.rb +0 -47
  53. data/lib/falcon/environments/proxy.rb +0 -37
  54. data/lib/falcon/environments/rack.rb +0 -50
  55. data/lib/falcon/environments/self_signed_tls.rb +0 -55
  56. data/lib/falcon/environments/supervisor.rb +0 -51
  57. data/lib/falcon/environments/tls.rb +0 -103
  58. data/lib/falcon/environments.rb +0 -31
  59. data/lib/falcon/service/application.rb +0 -115
  60. data/lib/falcon/service/generic.rb +0 -78
  61. data/lib/falcon/service/proxy.rb +0 -66
  62. data/lib/falcon/services.rb +0 -99
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 468c75f4ca09f1475236dd60cd3210245289f3fe56ae1c8c9735124a0d58da57
4
- data.tar.gz: 0a17770ff09718395672808de4039de00e7be385e97e4f1cf48221e99726c633
3
+ metadata.gz: deaf700b8a46f5af5e6e1151c0a0708789add0c2e66f4d6048e17da5e7da8c84
4
+ data.tar.gz: bac8d213a65f15c4bcc0741e86f357f1158ff2fedacb9480a00ce7ea3498de64
5
5
  SHA512:
6
- metadata.gz: 0ba625f50e2155ce5dc9e16c76a1f20585d17cb79232dcfd5cb040f78d3ee0e327834849f2fce1aaee6071e2815790936c6d4e6ad18825a0a944f340a1270a0d
7
- data.tar.gz: a560b603aa56a21fba8890c91aa5396768edbad9a2fd248c837eabbd1358ff81624dc675ddc46650792c68a73d29869a73b92ab91de71109b05b9cb1b3406ebb
6
+ metadata.gz: 40c405c0e768f68b1a4c56cbf7f155571240b30e8079051243e354596e32db76593929352ca70799d13cedd0fa1fe13afbbfb54edf6d1b0cb0c65d3edf7ea349
7
+ data.tar.gz: 9a94416a4b3f82cc34fe61e5b0cf1bdc23ab6c2190ed37d95ff11a9cfb4dfee204c855245d03715cd0d5b63f439451200752240bca2dce58336adc8f84b0c422
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Restart the application server via the supervisor.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2023, by Samuel Williams.
5
+
4
6
  def restart
5
7
  require_relative '../../lib/falcon/command/supervisor'
6
8
 
data/changes.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changes
2
+
3
+ # v0.44.0
4
+
5
+ ## Falcon Host
6
+
7
+ `async-service` is a new gem that exposes a generic service interface on top of `async-container`. Previously, `falcon host` used `async-container` directly and `build-environment` for configuration. In order to allow for more generic service definitions and configuration, `async-service` now provides a similar interface to `build-environment` and exposes this in a way that can be used for services other tha falcon. This makes it simpler to integrate multiple services into a single application.
8
+
9
+ The current configuration format uses definitions like this:
10
+
11
+ ```ruby
12
+ rack 'hello.localhost', :self_signed_tls
13
+ ```
14
+
15
+ This changes to:
16
+
17
+ ```ruby
18
+ service 'hello.localhost' do
19
+ include Falcon::Environment::Rack
20
+ include Falcon::Environment::SelfSignedTLS
21
+ end
22
+ ```
@@ -1,31 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2024, by Samuel Williams.
22
5
 
23
- require_relative '../controller/host'
24
- require_relative '../configuration'
6
+ require_relative 'paths'
25
7
  require_relative '../version'
26
8
 
27
9
  require 'samovar'
28
- require 'bundler'
10
+ require 'async/service/controller'
29
11
 
30
12
  module Falcon
31
13
  module Command
@@ -40,28 +22,13 @@ module Falcon
40
22
  # @attribute [Array(String)]
41
23
  many :paths, "Service configuration paths.", default: ["falcon.rb"]
42
24
 
25
+ include Paths
26
+
43
27
  # The container class to use.
44
28
  def container_class
45
29
  Async::Container.best_container_class
46
30
  end
47
31
 
48
- # Generate a configuration based on the specified {paths}.
49
- def configuration
50
- configuration = Configuration.new
51
-
52
- @paths.each do |path|
53
- path = File.expand_path(path)
54
- configuration.load_file(path)
55
- end
56
-
57
- return configuration
58
- end
59
-
60
- # Prepare a new controller for the command.
61
- def controller
62
- Controller::Host.new(self)
63
- end
64
-
65
32
  # Prepare the environment and run the controller.
66
33
  def call
67
34
  Console.logger.info(self) do |buffer|
@@ -71,17 +38,7 @@ module Falcon
71
38
  buffer.puts "- To reload: kill -HUP #{Process.pid}"
72
39
  end
73
40
 
74
- begin
75
- Bundler.require(:preload)
76
- rescue Bundler::GemfileNotFound
77
- # Ignore.
78
- end
79
-
80
- if GC.respond_to?(:compact)
81
- GC.compact
82
- end
83
-
84
- self.controller.run
41
+ Async::Service::Controller.run(self.configuration, container_class: self.container_class)
85
42
  end
86
43
  end
87
44
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2023, by Samuel Williams.
22
5
 
23
6
  require_relative '../configuration'
24
7
 
@@ -1,26 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
22
5
 
23
- require_relative '../controller/proxy'
6
+ require_relative '../environment/proxy'
24
7
  require_relative 'paths'
25
8
 
26
9
  require 'samovar'
@@ -48,20 +31,21 @@ module Falcon
48
31
 
49
32
  include Paths
50
33
 
51
- # Prepare a new controller for the command.
52
- def controller
53
- Controller::Proxy.new(self)
34
+ def environment(**options)
35
+ Async::Service::Environment.new(Falcon::Environment::Proxy).with(
36
+ root: Dir.pwd,
37
+ name: self.class.name,
38
+ verbose: self.parent&.verbose?,
39
+ url: @options[:bind],
40
+ timeout: @options[:timeout],
41
+ **options
42
+ )
54
43
  end
55
44
 
56
- # The container class to use.
57
- def container_class
58
- Async::Container.best_container_class
59
- end
60
-
61
- # Options for the container.
62
- # See {Controller::Serve#setup}.
63
- def container_options
64
- {}
45
+ def configuration
46
+ Configuration.for(
47
+ self.environment(environments: super.environments)
48
+ )
65
49
  end
66
50
 
67
51
  # Prepare the environment and run the controller.
@@ -71,9 +55,13 @@ module Falcon
71
55
  buffer.puts "- Binding to: #{@options[:bind]}"
72
56
  buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
73
57
  buffer.puts "- To reload: kill -HUP #{Process.pid}"
58
+
59
+ self.resolved_paths.each do |path|
60
+ buffer.puts "- Loading configuration from #{path}"
61
+ end
74
62
  end
75
63
 
76
- self.controller.run
64
+ Async::Service::Controller.run(self.configuration)
77
65
  end
78
66
 
79
67
  # The endpoint to bind to.
@@ -1,26 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
22
5
 
23
- require_relative '../controller/redirect'
6
+ require_relative '../environment/redirect'
24
7
  require_relative 'paths'
25
8
 
26
9
  require 'samovar'
@@ -46,20 +29,22 @@ module Falcon
46
29
 
47
30
  include Paths
48
31
 
49
- # Prepare a new controller for the command.
50
- def controller
51
- Controller::Redirect.new(self)
32
+ def environment(**options)
33
+ Async::Service::Environment.new(Falcon::Environment::Redirect).with(
34
+ root: Dir.pwd,
35
+ name: self.class.name,
36
+ verbose: self.parent&.verbose?,
37
+ url: @options[:bind],
38
+ redirect_url: @options[:redirect],
39
+ timeout: @options[:timeout],
40
+ **options
41
+ )
52
42
  end
53
43
 
54
- # The container class to use.
55
- def container_class
56
- Async::Container.best_container_class
57
- end
58
-
59
- # Options for the container.
60
- # See {Controller::Serve#setup}.
61
- def container_options
62
- {}
44
+ def configuration
45
+ Configuration.for(
46
+ self.environment(environments: super.environments)
47
+ )
63
48
  end
64
49
 
65
50
  # Prepare the environment and run the controller.
@@ -69,9 +54,13 @@ module Falcon
69
54
  buffer.puts "- Binding to: #{@options[:bind]}"
70
55
  buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
71
56
  buffer.puts "- To reload: kill -HUP #{Process.pid}"
57
+
58
+ self.resolved_paths.each do |path|
59
+ buffer.puts "- Loading configuration from #{path}"
60
+ end
72
61
  end
73
62
 
74
- self.controller.run
63
+ Async::Service::Controller.run(self.configuration)
75
64
  end
76
65
 
77
66
  # The endpoint to bind to.
@@ -1,42 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
+ # Copyright, 2018, by Mitsutaka Mimura.
22
6
 
23
7
  require_relative '../server'
24
8
  require_relative '../endpoint'
25
- require_relative '../controller/serve'
9
+ require_relative '../configuration'
10
+ require_relative '../service/server'
11
+ require_relative '../environment/rackup'
26
12
 
27
13
  require 'async/container'
28
-
29
- require 'async/io/trap'
30
- require 'async/io/host_endpoint'
31
- require 'async/io/shared_endpoint'
32
- require 'async/io/ssl_endpoint'
33
-
14
+ require 'async/http/client'
34
15
  require 'samovar'
35
16
 
36
- require 'rack/builder'
37
-
38
- require 'bundler'
39
-
40
17
  module Falcon
41
18
  module Command
42
19
  # Implements the `falcon serve` command. Designed for *development*.
@@ -67,6 +44,42 @@ module Falcon
67
44
  option '--threads <count>', "Number of threads (hybrid only).", type: Integer
68
45
  end
69
46
 
47
+ def container_options
48
+ @options.slice(:count, :forks, :threads)
49
+ end
50
+
51
+ def endpoint_options
52
+ @options.slice(:hostname, :port, :timeout)
53
+ end
54
+
55
+ def environment
56
+ Async::Service::Environment.new(Falcon::Environment::Server).with(
57
+ Falcon::Environment::Rackup,
58
+
59
+ root: Dir.pwd,
60
+
61
+ verbose: self.parent&.verbose?,
62
+ cache: @options[:cache],
63
+
64
+ container_options: self.container_options,
65
+ endpoint_options: self.endpoint_options,
66
+
67
+ rackup_path: @options[:config],
68
+ preload: [@options[:preload]].compact,
69
+ url: @options[:bind],
70
+
71
+ name: "server",
72
+
73
+ endpoint: ->{Endpoint.parse(url, **endpoint_options)}
74
+ )
75
+ end
76
+
77
+ def configuration
78
+ Configuration.new.tap do |configuration|
79
+ configuration.add(self.environment)
80
+ end
81
+ end
82
+
70
83
  # The container class to use.
71
84
  def container_class
72
85
  case @options[:container]
@@ -79,37 +92,6 @@ module Falcon
79
92
  end
80
93
  end
81
94
 
82
- # Whether verbose logging is enabled.
83
- # @returns [Boolean]
84
- def verbose?
85
- @parent&.verbose?
86
- end
87
-
88
- # Whether to enable the application HTTP cache.
89
- # @returns [Boolean]
90
- def cache?
91
- @options[:cache]
92
- end
93
-
94
- # Load the rack application from the specified configuration path.
95
- # @returns [Protocol::HTTP::Middleware]
96
- def load_app
97
- rack_app, _ = Rack::Builder.parse_file(@options[:config])
98
-
99
- return Server.middleware(rack_app, verbose: self.verbose?, cache: self.cache?)
100
- end
101
-
102
- # Options for the container.
103
- # See {Controller::Serve#setup}.
104
- def container_options
105
- @options.slice(:count, :forks, :threads)
106
- end
107
-
108
- # Options for the {endpoint}.
109
- def endpoint_options
110
- @options.slice(:hostname, :port, :reuse_port, :timeout)
111
- end
112
-
113
95
  # The endpoint to bind to.
114
96
  def endpoint
115
97
  Endpoint.parse(@options[:bind], **endpoint_options)
@@ -125,11 +107,6 @@ module Falcon
125
107
  Async::HTTP::Client.new(client_endpoint)
126
108
  end
127
109
 
128
- # Prepare a new controller for the command.
129
- def controller
130
- Controller::Serve.new(self)
131
- end
132
-
133
110
  # Prepare the environment and run the controller.
134
111
  def call
135
112
  Console.logger.info(self) do |buffer|
@@ -139,22 +116,7 @@ module Falcon
139
116
  buffer.puts "- To reload configuration: kill -HUP #{Process.pid}"
140
117
  end
141
118
 
142
- if path = @options[:preload]
143
- full_path = File.expand_path(path)
144
- load(full_path)
145
- end
146
-
147
- begin
148
- Bundler.require(:preload)
149
- rescue Bundler::GemfileNotFound
150
- # Ignore.
151
- end
152
-
153
- if GC.respond_to?(:compact)
154
- GC.compact
155
- end
156
-
157
- self.controller.run
119
+ Async::Service::Controller.run(self.configuration, container_class: self.container_class)
158
120
  end
159
121
  end
160
122
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
22
5
 
23
6
  require 'samovar'
24
7
  require 'async'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
22
5
 
23
6
  require_relative 'serve'
24
7
  require_relative 'host'
@@ -1,26 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
22
5
 
23
- require_relative '../controller/virtual'
6
+ require_relative '../service/virtual'
24
7
  require_relative 'paths'
25
8
 
26
9
  require 'samovar'
@@ -47,26 +30,20 @@ module Falcon
47
30
  # @attribute [Array(String)]
48
31
  many :paths
49
32
 
50
- include Paths
51
-
52
- # Prepare a new controller for the command.
53
- def controller
54
- Controller::Virtual.new(self)
55
- end
56
-
57
- # The URI to bind the `HTTPS` -> `falcon host` proxy.
58
- def bind_secure
59
- @options[:bind_secure]
33
+ def environment
34
+ Async::Service::Environment.new(Falcon::Service::Virtual::Environment).with(
35
+ verbose: self.parent&.verbose?,
36
+ configuration_paths: self.paths,
37
+ bind_insecure: @options[:bind_insecure],
38
+ bind_secure: @options[:bind_secure],
39
+ timeout: @options[:timeout],
40
+ )
60
41
  end
61
42
 
62
- # The URI to bind the `HTTP` -> `HTTPS` redirector.
63
- def bind_insecure
64
- @options[:bind_insecure]
65
- end
66
-
67
- # The connection timeout to use for incoming connections.
68
- def timeout
69
- @options[:timeout]
43
+ def configuration
44
+ Async::Service::Configuration.new.tap do |configuration|
45
+ configuration.add(self.environment)
46
+ end
70
47
  end
71
48
 
72
49
  # Prepare the environment and run the controller.
@@ -77,9 +54,7 @@ module Falcon
77
54
  buffer.puts "- To reload all sites: kill -HUP #{Process.pid}"
78
55
  end
79
56
 
80
- ENV['CONSOLE_LEVEL'] = 'debug'
81
-
82
- self.controller.run
57
+ Async::Service::Controller.run(self.configuration)
83
58
  end
84
59
 
85
60
  # The insecure endpoint for connecting to the {Redirect} instance.
@@ -1,24 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2017-2023, by Samuel Williams.
5
+ # Copyright, 2018, by Mitsutaka Mimura.
22
6
 
23
7
  require_relative 'command/top'
24
8