Method: Temporalio::Runtime#initialize
- Defined in:
- lib/temporalio/runtime.rb
#initialize(telemetry: TelemetryOptions.new, worker_heartbeat_interval: 60) ⇒ 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.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/temporalio/runtime.rb', line 335 def initialize( telemetry: TelemetryOptions.new, worker_heartbeat_interval: 60 ) if !worker_heartbeat_interval.nil? && !worker_heartbeat_interval.positive? raise 'Worker heartbeat interval must be positive' end # Set runtime on the buffer which will fail if the buffer is used on another runtime telemetry.metrics&.buffer&._set_runtime(self) @core_runtime = Internal::Bridge::Runtime.new( Internal::Bridge::Runtime::Options.new( telemetry: telemetry._to_bridge, worker_heartbeat_interval: ) ) @metric_meter = Internal::Metric::Meter.create_from_runtime(self) || Metric::Meter.null # 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 |