Class: Temporalio::Runtime
- Inherits:
-
Object
- Object
- Temporalio::Runtime
- Defined in:
- lib/temporalio/runtime.rb
Overview
Runtime for Temporal Ruby SDK.
Only one global Runtime needs to exist. Users are encouraged to use Runtime.default. To configure it, create a runtime before any clients are created, and set it via Runtime.default=. Every time a new runtime is created, a new internal Rust thread pool is created.
Defined Under Namespace
Classes: LoggingFilterOptions, LoggingOptions, MetricsOptions, OpenTelemetryMetricsOptions, PrometheusMetricsOptions, TelemetryOptions
Class Method Summary collapse
-
.default ⇒ Runtime
Default runtime, lazily created upon first access.
-
.default=(runtime) ⇒ Object
Set the default runtime.
Instance Method Summary collapse
-
#initialize(telemetry: TelemetryOptions.new) ⇒ Runtime
constructor
Create new Runtime.
Constructor Details
#initialize(telemetry: TelemetryOptions.new) ⇒ Runtime
Create new Runtime. For most users, this should only be done once globally. In addition to creating a Rust thread pool, this also consumes a Ruby thread for its lifetime.
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/temporalio/runtime.rb', line 255 def initialize(telemetry: TelemetryOptions.new) @core_runtime = Internal::Bridge::Runtime.new( Internal::Bridge::Runtime::Options.new(telemetry: telemetry._to_bridge) ) # We need a thread to run the command loop # TODO(cretz): Is this something users should be concerned about or need control over? Thread.new do @core_runtime.run_command_loop end end |
Class Method Details
.default ⇒ Runtime
237 238 239 |
# File 'lib/temporalio/runtime.rb', line 237 def self.default @default ||= Runtime.new end |
.default=(runtime) ⇒ Object
Set the default runtime. Must be called before default accessed.
245 246 247 248 249 |
# File 'lib/temporalio/runtime.rb', line 245 def self.default=(runtime) raise 'Runtime already set or requested' unless @default.nil? @default = runtime end |