class TrinoRuntime
Low-coupling facade for the Trino engine. Phase 3 shipped the fake adapter so the whole state machine runs without a cluster; Phase 5 adds the real one. Set TRINO_RUNTIME=real (plus the TRINO* and KUBE* env vars) in production.
Public Class Methods
Source
# File app/services/trino_runtime.rb, line 48 def self.adapter @adapter ||= build_adapter end
The cached runtime adapter, building it on first use.
@return [TrinoRuntime] the adapter
Source
# File app/services/trino_runtime.rb, line 55 def self.adapter=(adapter) @adapter = adapter end
Replaces the runtime adapter (used by tests).
@param adapter [TrinoRuntime] the adapter to use
Source
# File app/services/trino_runtime.rb, line 67 def self.build_adapter return RealTrinoRuntime.new if ENV["TRINO_RUNTIME"] == "real" FakeTrinoRuntime.new end
Builds the real or fake adapter from the TRINO_RUNTIME env var.
@return [TrinoRuntime] the adapter
Source
# File app/services/trino_runtime.rb, line 16 def self.ensure_running adapter.ensure_running end
Ensures the engine is running via the current adapter.
Source
# File app/services/trino_runtime.rb, line 21 def self.ensure_stopped adapter.ensure_stopped end
Ensures the engine is stopped via the current adapter.
# File app/services/trino_runtime.rb, line 32 def self.execute(sql, execution_id:, execution: nil, step: nil) adapter.execute(sql, execution_id: execution_id, execution: execution, step: step) end
Executes SQL through the current adapter.
@param sql [String] the query @param execution_id [Integer] the execution id for tracking @param execution [ExecutionHistory, nil] the execution for heartbeats @param step [ExecutionStep, nil] the step for query id/progress @return [Hash] the result payload
# File app/services/trino_runtime.rb, line 41 def self.query_rows(sql, execution_id:) adapter.query_rows(sql, execution_id: execution_id) end
Runs a helper SQL query and returns the actual data rows.
@param sql [String] the query @param execution_id [Integer] the execution id for headers @return [Array<Array>] the data rows
Source
# File app/services/trino_runtime.rb, line 11 def self.ready? adapter.ready? end
Whether the current adapterโs engine is ready.
@return [Boolean] true when ready
Source
# File app/services/trino_runtime.rb, line 60 def self.reset_adapter! @adapter = nil end
Clears the cached adapter so the next call rebuilds it.