Class: Hyperion::Config::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperion/config.rb

Overview

DSL receiver. Each method call on the DSL maps to a Config setter or to a hook registration. Unknown methods raise NoMethodError so typos surface immediately at boot rather than as silent ignores.

1.7.0 (RFC A4) added nested block forms — ‘h2 do |h| … end` and the bare-block `worker_health do; max_rss_mb 1024; end` shape. The flat `h2_max_concurrent_streams 256` form keeps working untouched in 1.7; deprecation warn lands in 1.8, removal in 2.0.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DSL

Returns a new instance of DSL.



418
419
420
# File 'lib/hyperion/config.rb', line 418

def initialize(config)
  @config = config
end

Instance Method Details

#bind(value) ⇒ Object

‘bind` is the Puma-style alias for `host` — operators expect it.



423
424
425
# File 'lib/hyperion/config.rb', line 423

def bind(value)
  @config.host = value
end

#preload_static(path, immutable: true) ⇒ Object

2.10-E — ‘preload_static “/path”, immutable: true` DSL key. Appends `immutable:` onto `preload_static_dirs`. The `immutable:` kwarg defaults to true — the whole point of preload is “I promise these don’t change without a restart” so the immutable flag is the operator-friendly default. Multiple calls accumulate.

Overrides the auto-generated DEFAULTS-based setter for the backing field (which would write the entire array via ‘=`); this explicit method is the one the DSL actually exposes.



490
491
492
# File 'lib/hyperion/config.rb', line 490

def preload_static(path, immutable: true)
  @config.preload_static_dirs << { path: path.to_s, immutable: immutable }
end

#tls_cert_path(path) ⇒ Object

‘tls_cert_path` / `tls_key_path` are convenience aliases that read the file off disk so the DSL stays terse. The parsed cert/key are stored on the config and Server consumes them directly.



470
471
472
473
# File 'lib/hyperion/config.rb', line 470

def tls_cert_path(path)
  require 'openssl'
  @config.tls_cert = OpenSSL::X509::Certificate.new(File.read(path))
end

#tls_key_path(path) ⇒ Object



475
476
477
478
# File 'lib/hyperion/config.rb', line 475

def tls_key_path(path)
  require 'openssl'
  @config.tls_key = OpenSSL::PKey.read(File.read(path))
end