Module: Kino

Defined in:
lib/kino.rb,
lib/kino/cli.rb,
lib/kino/log.rb,
lib/kino/check.rb,
lib/kino/input.rb,
lib/kino/logger.rb,
lib/kino/server.rb,
lib/kino/stream.rb,
lib/kino/worker.rb,
lib/kino/version.rb,
lib/kino/hook_fire.rb,
lib/kino/null_input.rb,
lib/kino/worker_hooks.rb,
lib/kino/configuration.rb,
lib/kino/errors_stream.rb,
lib/kino/ractor_supervisor.rb,
lib/kino/quarantine_monitor.rb

Overview

A high-performance Ractor web server for Ruby 4.0+: Rack 3-based, with a Rust (tokio + hyper) front-end and Ractor-parallel Ruby workers, plus a threaded fallback mode for apps (such as Rails) that are not Ractor-shareable.

The public API is Server, Configuration, Check, Logger, and Kino.sleep; the kino executable is implemented by CLI.

Defined Under Namespace

Modules: CLI, Check, Log Classes: Configuration, Error, Logger, Server, UnshareableAppError

Constant Summary collapse

VERSION =

The gem version (single source of truth; ext/kino/Cargo.toml syncs).

"0.4.0"

Class Method Summary collapse

Class Method Details

.available_parallelismInteger

How many CPUs this process may actually use: the workers default. Unlike Etc.nprocessors, this honours a cgroup CPU quota (a container limited to 2 CPUs on a 64-core host gets 2, not 64) as well as the affinity mask; a fractional quota rounds up. Never below 1.

Returns:

  • (Integer)


43
44
45
# File 'lib/kino.rb', line 43

def self.available_parallelism
  Native.available_parallelism
end

.sleep(seconds) ⇒ nil

High-resolution sleep that bypasses the VM timer (whose wakeups inside non-main ractors are coarse: ~+2.5ms on Linux). Sleeps on the OS clock with the GVL released; chunked so Thread#kill and shutdown interrupts are honored between chunks.

Parameters:

  • seconds (Numeric)

    how long to sleep; must be non-negative

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    for negative or non-numeric durations



29
30
31
32
33
34
35
# File 'lib/kino.rb', line 29

def self.sleep(seconds)
  remaining = Float(seconds)
  raise ArgumentError, "sleep duration must be non-negative" if remaining.negative?

  remaining = Native.sleep_chunk(remaining) while remaining.positive?
  nil
end