Class: Falcon::Command::Proxy
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Proxy
- Includes:
- Paths
- Defined in:
- lib/falcon/command/proxy.rb
Overview
Implements the ‘falcon proxy` command.
Manages a Controller::Proxy instance which is responsible for proxing incoming requests.
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
One or more paths to the configuration files.
Instance Method Summary collapse
-
#call ⇒ Object
Prepare the environment and run the controller.
-
#configuration ⇒ Object
Build the service configuration for the proxy.
-
#endpoint(**options) ⇒ Object
The endpoint to bind to.
-
#environment(**options) ⇒ Object
Create the environment for the proxy service.
Methods included from Paths
Instance Attribute Details
#paths ⇒ Object (readonly)
One or more paths to the configuration files.
30 |
# File 'lib/falcon/command/proxy.rb', line 30 many :paths |
Instance Method Details
#call ⇒ Object
Prepare the environment and run the controller.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/falcon/command/proxy.rb', line 57 def call Console.info(self) do |buffer| buffer.puts "Falcon Proxy v#{VERSION} taking flight!" buffer.puts "- Binding to: #{@options[:bind]}" buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}" buffer.puts "- To reload: kill -HUP #{Process.pid}" self.resolved_paths do |path| buffer.puts "- Loading configuration from #{path}" end end Async::Service::Controller.run(self.configuration) end |
#configuration ⇒ Object
Build the service configuration for the proxy.
50 51 52 53 54 |
# File 'lib/falcon/command/proxy.rb', line 50 def configuration Async::Service::Configuration.for( self.environment(environments: super.environments) ) end |
#endpoint(**options) ⇒ Object
The endpoint to bind to.
73 74 75 |
# File 'lib/falcon/command/proxy.rb', line 73 def endpoint(**) Async::HTTP::Endpoint.parse(@options[:bind], timeout: @options[:timeout], **) end |
#environment(**options) ⇒ Object
Create the environment for the proxy service.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/falcon/command/proxy.rb', line 37 def environment(**) Async::Service::Environment.new(Falcon::Environment::Proxy).with( root: Dir.pwd, name: self.class.name, verbose: self.parent&.verbose?, url: @options[:bind], timeout: @options[:timeout], ** ) end |