Class: Kino::Configuration::DSL
- Inherits:
-
Object
- Object
- Kino::Configuration::DSL
- Defined in:
- lib/kino/configuration.rb
Overview
The config-file DSL, deliberately Puma-shaped:
# kino.rb
bind "0.0.0.0"
port 9292
workers 8 # ractors (or thread groups in :threaded mode)
threads 3 # threads per worker
mode :ractor # :auto | :ractor | :threaded
queue_depth 2048
queue_timeout 0.5
shutdown_timeout 15
tokio_threads 4
tls cert: "cert.pem", key: "key.pem"
Every directive is documented in the generated sample config
(kino --init); the one-liners here only state the value each
directive expects.
Instance Method Summary collapse
-
#batch(count) ⇒ Object
Requests a worker may grab per queue visit (default 1).
-
#bind(host) ⇒ Object
Address to listen on ("0.0.0.0" accepts non-local connections).
-
#environment(env) ⇒ Object
Sets RACK_ENV (unless already set) before the CLI loads the app.
-
#initialize(config) ⇒ DSL
constructor
A new instance of DSL.
-
#lanes(enabled) ⇒ Object
EXPERIMENTAL per-worker lane dispatch.
-
#log_requests(enabled) ⇒ Object
Native access log: one status-colored line per request to stdout.
-
#max_body_size(bytes) ⇒ Object
Max request-body bytes before a 413; nil disables (delegate to a fronting proxy).
-
#max_connections(count) ⇒ Object
Max connections served at once; beyond it, new connections wait in the kernel backlog.
-
#mode(mode) ⇒ Object
Dispatch mode: :auto, :ractor, or :threaded.
-
#on_error(handler = nil, &block) ⇒ Object
Called with (exception, env) when a worker catches an app or delivery error; wire your error tracker here.
-
#pidfile(path) ⇒ Object
Write the master PID here on start.
-
#port(port) ⇒ Object
Port to listen on; 0 picks an ephemeral port.
-
#queue_depth(depth) ⇒ Object
Bounded request-queue depth; overflow earns clients a 503.
-
#queue_timeout(seconds) ⇒ Object
Seconds a request may wait for queue space before the 503.
-
#rackup(path) ⇒ Object
Rackup file the
kinoCLI loads (positional argument wins). -
#request_timeout(seconds) ⇒ Object
Seconds the app gets before the client receives a 504; nil = off.
-
#shutdown_timeout(seconds) ⇒ Object
Graceful-shutdown drain deadline in seconds.
-
#threads(count) ⇒ Object
Threads per worker (I/O concurrency inside one ractor); default is mode-dependent: 1 in :ractor mode, 3 in :threaded.
-
#tls(cert:, key:) ⇒ Object
TLS termination; file paths or inline PEM strings.
-
#tokio_threads(count) ⇒ Object
Threads for the tokio (Rust I/O) runtime; default: one per core.
-
#workers(count) ⇒ Object
Worker count (ractors in :ractor mode); defaults to CPU cores.
Constructor Details
#initialize(config) ⇒ DSL
Returns a new instance of DSL.
137 138 139 |
# File 'lib/kino/configuration.rb', line 137 def initialize(config) @config = config end |
Instance Method Details
#batch(count) ⇒ Object
Requests a worker may grab per queue visit (default 1).
175 |
# File 'lib/kino/configuration.rb', line 175 def batch(count) = @config.set(:batch, Integer(count)) |
#bind(host) ⇒ Object
Address to listen on ("0.0.0.0" accepts non-local connections).
142 |
# File 'lib/kino/configuration.rb', line 142 def bind(host) = @config.set(:bind, host) |
#environment(env) ⇒ Object
Sets RACK_ENV (unless already set) before the CLI loads the app.
198 |
# File 'lib/kino/configuration.rb', line 198 def environment(env) = @config.set(:environment, env.to_s) |
#lanes(enabled) ⇒ Object
EXPERIMENTAL per-worker lane dispatch.
178 |
# File 'lib/kino/configuration.rb', line 178 def lanes(enabled) = @config.set(:lanes, !!enabled) |
#log_requests(enabled) ⇒ Object
Native access log: one status-colored line per request to stdout.
181 |
# File 'lib/kino/configuration.rb', line 181 def log_requests(enabled) = @config.set(:log_requests, !!enabled) |
#max_body_size(bytes) ⇒ Object
Max request-body bytes before a 413; nil disables (delegate to a fronting proxy). Default 50 MB.
172 |
# File 'lib/kino/configuration.rb', line 172 def max_body_size(bytes) = @config.set(:max_body_size, bytes && Integer(bytes)) |
#max_connections(count) ⇒ Object
Max connections served at once; beyond it, new connections wait in the kernel backlog. Defaults to most of the open-file limit.
168 |
# File 'lib/kino/configuration.rb', line 168 def max_connections(count) = @config.set(:max_connections, Integer(count)) |
#mode(mode) ⇒ Object
Dispatch mode: :auto, :ractor, or :threaded.
155 |
# File 'lib/kino/configuration.rb', line 155 def mode(mode) = @config.set(:mode, mode.to_sym) |
#on_error(handler = nil, &block) ⇒ Object
Called with (exception, env) when a worker catches an app or delivery error; wire your error tracker here. Takes a callable or a block. Must be Ractor-shareable in :ractor mode.
186 |
# File 'lib/kino/configuration.rb', line 186 def on_error(handler = nil, &block) = @config.set(:on_error, handler || block) |
#pidfile(path) ⇒ Object
Write the master PID here on start.
201 |
# File 'lib/kino/configuration.rb', line 201 def pidfile(path) = @config.set(:pidfile, path.to_s) |
#port(port) ⇒ Object
Port to listen on; 0 picks an ephemeral port.
145 |
# File 'lib/kino/configuration.rb', line 145 def port(port) = @config.set(:port, Integer(port)) |
#queue_depth(depth) ⇒ Object
Bounded request-queue depth; overflow earns clients a 503.
158 |
# File 'lib/kino/configuration.rb', line 158 def queue_depth(depth) = @config.set(:queue_depth, Integer(depth)) |
#queue_timeout(seconds) ⇒ Object
Seconds a request may wait for queue space before the 503.
161 |
# File 'lib/kino/configuration.rb', line 161 def queue_timeout(seconds) = @config.set(:queue_timeout, Float(seconds)) |
#rackup(path) ⇒ Object
Rackup file the kino CLI loads (positional argument wins).
204 |
# File 'lib/kino/configuration.rb', line 204 def rackup(path) = @config.set(:rackup, path.to_s) |
#request_timeout(seconds) ⇒ Object
Seconds the app gets before the client receives a 504; nil = off.
164 |
# File 'lib/kino/configuration.rb', line 164 def request_timeout(seconds) = @config.set(:request_timeout, seconds && Float(seconds)) |
#shutdown_timeout(seconds) ⇒ Object
Graceful-shutdown drain deadline in seconds.
189 |
# File 'lib/kino/configuration.rb', line 189 def shutdown_timeout(seconds) = @config.set(:shutdown_timeout, seconds) |
#threads(count) ⇒ Object
Threads per worker (I/O concurrency inside one ractor); default is mode-dependent: 1 in :ractor mode, 3 in :threaded.
152 |
# File 'lib/kino/configuration.rb', line 152 def threads(count) = @config.set(:threads, Integer(count)) |
#tls(cert:, key:) ⇒ Object
TLS termination; file paths or inline PEM strings.
195 |
# File 'lib/kino/configuration.rb', line 195 def tls(cert:, key:) = @config.set(:tls, {cert: cert, key: key}) |
#tokio_threads(count) ⇒ Object
Threads for the tokio (Rust I/O) runtime; default: one per core.
192 |
# File 'lib/kino/configuration.rb', line 192 def tokio_threads(count) = @config.set(:tokio_threads, Integer(count)) |
#workers(count) ⇒ Object
Worker count (ractors in :ractor mode); defaults to CPU cores.
148 |
# File 'lib/kino/configuration.rb', line 148 def workers(count) = @config.set(:workers, Integer(count)) |