Class: Hyperion::Config
- Inherits:
-
Object
- Object
- Hyperion::Config
- Defined in:
- lib/hyperion/config.rb
Overview
Mutable configuration container — populated by the DSL evaluator (Hyperion::Config.load) and then read by CLI / Server / Master / Worker / Connection / Logger.
All settings have safe defaults that match the per-class DEFAULT_* constants so that running Hyperion without a config file works identically to the pre-rc14 behaviour.
Defined Under Namespace
Classes: DSL
Constant Summary collapse
- DEFAULTS =
{ host: '127.0.0.1', port: 9292, workers: 1, thread_count: 5, tls_cert: nil, tls_key: nil, read_timeout: 30, idle_keepalive: 5, graceful_timeout: 30, max_header_bytes: 64 * 1024, max_body_bytes: 16 * 1024 * 1024, log_level: nil, # nil → Logger picks from env / default log_format: nil, # nil → Logger picks via auto rule log_requests: nil, # nil → Hyperion.log_requests? (default true) fiber_local_shim: false, yjit: nil, # nil → auto: enable on production/staging; true/false to force. worker_max_rss_mb: nil, # Integer, e.g. 1024. When a worker exceeds this RSS in MB, master gracefully cycles it. nil disables. worker_check_interval: 30, # Seconds between RSS polls. Tradeoff: tighter = faster recycle, more ps calls. 30s matches Puma WorkerKiller. admin_token: nil # String. When set, POST /-/quit triggers graceful drain. nil disables endpoint entirely (returns 404). }.freeze
- HOOKS =
%i[before_fork on_worker_boot on_worker_shutdown].freeze
Class Method Summary collapse
-
.load(path) ⇒ Object
Load a Ruby DSL config file.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#merge_cli!(overrides) ⇒ Object
Apply CLI overrides on top of an existing config.
Constructor Details
Class Method Details
.load(path) ⇒ Object
Load a Ruby DSL config file. Returns the populated Config. Path is the operator-supplied –config argument; we evaluate it in a DSL context that maps method calls to attribute setters.
53 54 55 56 57 58 |
# File 'lib/hyperion/config.rb', line 53 def self.load(path) cfg = new contents = File.read(path) DSL.new(cfg).instance_eval(contents, path) cfg end |
Instance Method Details
#merge_cli!(overrides) ⇒ Object
Apply CLI overrides on top of an existing config. Only non-nil values in ‘overrides` are applied — preserves the precedence ordering (CLI > env > config file > default).
63 64 65 66 67 68 69 70 |
# File 'lib/hyperion/config.rb', line 63 def merge_cli!(overrides) overrides.each do |key, value| next if value.nil? public_send(:"#{key}=", value) if respond_to?(:"#{key}=") end self end |