Class: Kino::Configuration::DSL

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(config) ⇒ DSL

Returns a new instance of DSL.



136
137
138
# File 'lib/kino/configuration.rb', line 136

def initialize(config)
  @config = config
end

Instance Method Details

#batch(count) ⇒ Object

Requests a worker may grab per queue visit (default 1).



174
# File 'lib/kino/configuration.rb', line 174

def batch(count) = @config.set(:batch, Integer(count))

#bind(host) ⇒ Object

Address to listen on ("0.0.0.0" accepts non-local connections).



141
# File 'lib/kino/configuration.rb', line 141

def bind(host) = @config.set(:bind, host)

#environment(env) ⇒ Object

Sets RACK_ENV (unless already set) before the CLI loads the app.



192
# File 'lib/kino/configuration.rb', line 192

def environment(env) = @config.set(:environment, env.to_s)

#lanes(enabled) ⇒ Object

EXPERIMENTAL per-worker lane dispatch.



177
# File 'lib/kino/configuration.rb', line 177

def lanes(enabled) = @config.set(:lanes, !!enabled)

#log_requests(enabled) ⇒ Object

Native access log: one status-colored line per request to stdout.



180
# File 'lib/kino/configuration.rb', line 180

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.



171
# File 'lib/kino/configuration.rb', line 171

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.



167
# File 'lib/kino/configuration.rb', line 167

def max_connections(count) = @config.set(:max_connections, Integer(count))

#mode(mode) ⇒ Object

Dispatch mode: :auto, :ractor, or :threaded.



154
# File 'lib/kino/configuration.rb', line 154

def mode(mode) = @config.set(:mode, mode.to_sym)

#pidfile(path) ⇒ Object

Write the master PID here on start.



195
# File 'lib/kino/configuration.rb', line 195

def pidfile(path) = @config.set(:pidfile, path.to_s)

#port(port) ⇒ Object

Port to listen on; 0 picks an ephemeral port.



144
# File 'lib/kino/configuration.rb', line 144

def port(port) = @config.set(:port, Integer(port))

#queue_depth(depth) ⇒ Object

Bounded request-queue depth; overflow earns clients a 503.



157
# File 'lib/kino/configuration.rb', line 157

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.



160
# File 'lib/kino/configuration.rb', line 160

def queue_timeout(seconds) = @config.set(:queue_timeout, Float(seconds))

#rackup(path) ⇒ Object

Rackup file the kino CLI loads (positional argument wins).



198
# File 'lib/kino/configuration.rb', line 198

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.



163
# File 'lib/kino/configuration.rb', line 163

def request_timeout(seconds) = @config.set(:request_timeout, seconds && Float(seconds))

#shutdown_timeout(seconds) ⇒ Object

Graceful-shutdown drain deadline in seconds.



183
# File 'lib/kino/configuration.rb', line 183

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.



151
# File 'lib/kino/configuration.rb', line 151

def threads(count) = @config.set(:threads, Integer(count))

#tls(cert:, key:) ⇒ Object

TLS termination; file paths or inline PEM strings.



189
# File 'lib/kino/configuration.rb', line 189

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.



186
# File 'lib/kino/configuration.rb', line 186

def tokio_threads(count) = @config.set(:tokio_threads, Integer(count))

#workers(count) ⇒ Object

Worker count (ractors in :ractor mode); defaults to CPU cores.



147
# File 'lib/kino/configuration.rb', line 147

def workers(count) = @config.set(:workers, Integer(count))