Class: Gjallarhorn::Proxy::Manager
- Inherits:
-
Object
- Object
- Gjallarhorn::Proxy::Manager
- Defined in:
- lib/gjallarhorn/proxy/manager.rb
Overview
Base proxy manager class
Handles traffic routing and switching during deployments. Supports different proxy types (nginx, traefik, kamal-proxy) for zero-downtime deployments.
Direct Known Subclasses
Instance Attribute Summary collapse
- #config ⇒ Object readonly
- #logger ⇒ Object readonly
- #proxy_type ⇒ Object readonly
Class Method Summary collapse
-
.create(config, logger = nil) ⇒ Manager
Create appropriate proxy manager based on configuration.
Instance Method Summary collapse
-
#healthy? ⇒ Boolean
Check if proxy is healthy.
-
#initialize(config, logger = nil) ⇒ Manager
constructor
Initialize proxy manager.
-
#restart ⇒ Boolean
Restart proxy service.
-
#status ⇒ Hash
Get proxy status.
-
#switch_traffic(service_name:, from_containers:, to_container:) ⇒ void
abstract
Switch traffic from old containers to new container.
Constructor Details
#initialize(config, logger = nil) ⇒ Manager
Initialize proxy manager
19 20 21 22 23 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 19 def initialize(config, logger = nil) @config = config @proxy_type = config[:type] || "nginx" @logger = logger || Logger.new($stdout) end |
Instance Attribute Details
#config ⇒ Object (readonly)
13 14 15 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 13 def config @config end |
#logger ⇒ Object (readonly)
13 14 15 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 13 def logger @logger end |
#proxy_type ⇒ Object (readonly)
13 14 15 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 13 def proxy_type @proxy_type end |
Class Method Details
.create(config, logger = nil) ⇒ Manager
Create appropriate proxy manager based on configuration
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 67 def self.create(config, logger = nil) case config[:type] when "nginx" NginxManager.new(config, logger) when "traefik" TraefikManager.new(config, logger) when "kamal-proxy" KamalProxyManager.new(config, logger) else raise ConfigurationError, "Unsupported proxy type: #{config[:type]}" end end |
Instance Method Details
#healthy? ⇒ Boolean
Check if proxy is healthy
58 59 60 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 58 def healthy? false # Default implementation end |
#restart ⇒ Boolean
Restart proxy service
50 51 52 53 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 50 def restart @logger.info "Restarting #{@proxy_type} proxy..." false # Default implementation end |
#status ⇒ Hash
Get proxy status
39 40 41 42 43 44 45 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 39 def status { type: @proxy_type, status: "unknown", upstreams: [] } end |
#switch_traffic(service_name:, from_containers:, to_container:) ⇒ void
This method is abstract.
Subclasses should implement this method
This method returns an undefined value.
Switch traffic from old containers to new container
32 33 34 |
# File 'lib/gjallarhorn/proxy/manager.rb', line 32 def switch_traffic(service_name:, from_containers:, to_container:) raise NotImplementedError, "Subclasses must implement switch_traffic" end |