Module: Hyperion

Defined in:
lib/hyperion.rb,
lib/hyperion/cli.rb,
lib/hyperion/tls.rb,
lib/hyperion/pool.rb,
lib/hyperion/config.rb,
lib/hyperion/logger.rb,
lib/hyperion/master.rb,
lib/hyperion/parser.rb,
lib/hyperion/server.rb,
lib/hyperion/worker.rb,
lib/hyperion/metrics.rb,
lib/hyperion/request.rb,
lib/hyperion/version.rb,
lib/hyperion/connection.rb,
lib/hyperion/fiber_local.rb,
lib/hyperion/thread_pool.rb,
lib/hyperion/adapter/rack.rb,
lib/hyperion/http2_handler.rb,
lib/hyperion/worker_health.rb,
lib/hyperion/response_writer.rb,
lib/hyperion/admin_middleware.rb

Defined Under Namespace

Modules: Adapter, FiberLocal, TLS, WorkerHealth Classes: AdminMiddleware, CLI, CParser, Config, Connection, Error, Http2Handler, Logger, Master, Metrics, ParseError, Parser, Pool, Request, ResponseWriter, Server, ThreadPool, UnsupportedError, Worker

Constant Summary collapse

VERSION =
'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.log_requests=(value) ⇒ Object (writeonly)

Sets the attribute log_requests

Parameters:

  • value

    the value to set the attribute log_requests to.



18
19
20
# File 'lib/hyperion.rb', line 18

def log_requests=(value)
  @log_requests = value
end

.loggerObject



14
15
16
# File 'lib/hyperion.rb', line 14

def logger
  @logger ||= Logger.new
end

Class Method Details

.c_parser_available?Boolean

Whether the llhttp C extension loaded. False on JRuby/TruffleRuby and any environment where extconf.rb / make failed at install time. The pure-Ruby parser handles those cases correctly but is ~2× slower on parse-heavy workloads. Operators running production should confirm this returns true; CLI emits a startup banner if it doesn’t.

Returns:

  • (Boolean)


41
42
43
# File 'lib/hyperion.rb', line 41

def c_parser_available?
  defined?(::Hyperion::CParser) && ::Hyperion::CParser.respond_to?(:build_response_head)
end

.log_requests?Boolean

Per-request access logging is ON by default — matches Puma/Rails operator expectations (Rails::Rack::Logger emits one line per request out of the box). Operators can disable it via ‘–no-log-requests`, `HYPERION_LOG_REQUESTS=0|false|no|off`, or programmatically via `Hyperion.log_requests = false`. When false, Connection skips ALL access-log work — no Process.clock_gettime, no hash build, nothing.

The hot path uses Logger#access (single-interpolation line build, per-thread cached timestamp, lock-free emit) so default-ON throughput stays well above Puma’s default-OFF baseline.

Returns:

  • (Boolean)


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/hyperion.rb', line 55

def log_requests?
  return @log_requests unless @log_requests.nil?

  env = ENV['HYPERION_LOG_REQUESTS']&.downcase
  @log_requests =
    case env
    when '0', 'false', 'no', 'off' then false
    when '1', 'true', 'yes', 'on'  then true
    else true # default ON
    end
end

.metricsObject



20
21
22
# File 'lib/hyperion.rb', line 20

def metrics
  @metrics ||= Metrics.new
end

.statsObject



24
25
26
# File 'lib/hyperion.rb', line 24

def stats
  metrics.snapshot
end

.yjit_enabled?Boolean

Whether YJIT is currently enabled in this Ruby process. False on Rubies that don’t ship YJIT (JRuby, TruffleRuby) and on CRuby builds compiled without YJIT support. Cheap (no allocations) — safe to call from hot paths if needed for diagnostics.

Returns:

  • (Boolean)


32
33
34
# File 'lib/hyperion.rb', line 32

def yjit_enabled?
  defined?(::RubyVM::YJIT) && ::RubyVM::YJIT.enabled?
end