Class: Zeridion::Flare::Worker::Runner
- Inherits:
-
Object
- Object
- Zeridion::Flare::Worker::Runner
- Defined in:
- lib/zeridion_flare/worker/runner.rb
Overview
The poll loop. Runs register-once → poll → dispatch → ack, and bounds
the poll capacity to true free slots clamped 1–50. Owns no threads of
its own beyond the per-job heartbeat pumps it starts; the bounded job
threads live in the Pool. Mirrors the reference SDK's poll-loop service.
Constant Summary collapse
- CAPACITY_MIN =
1- CAPACITY_MAX =
50
Instance Method Summary collapse
-
#initialize(worker_id:, config:, registry:, executor:, pool:, poll_client:, heartbeat_client:, ack_client:, register_client:, stop_token:, logger: nil) ⇒ Runner
constructor
A new instance of Runner.
-
#run ⇒ Object
Run the loop on the CURRENT thread until the stop token trips.
Constructor Details
#initialize(worker_id:, config:, registry:, executor:, pool:, poll_client:, heartbeat_client:, ack_client:, register_client:, stop_token:, logger: nil) ⇒ Runner
Returns a new instance of Runner.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/zeridion_flare/worker/runner.rb', line 25 def initialize(worker_id:, config:, registry:, executor:, pool:, poll_client:, heartbeat_client:, ack_client:, register_client:, stop_token:, logger: nil) @worker_id = worker_id @config = config @registry = registry @executor = executor @pool = pool @poll_client = poll_client @heartbeat_client = heartbeat_client @ack_client = ack_client @register_client = register_client @stop = stop_token @logger = logger end |
Instance Method Details
#run ⇒ Object
Run the loop on the CURRENT thread until the stop token trips. The caller (Worker) decides whether that is the main thread or a spawned poll thread.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/zeridion_flare/worker/runner.rb', line 44 def run if @registry.empty? @logger&.warn("worker_starting no job types discovered — worker will not poll") return end queues = poll_queues job_types = @registry.job_types @logger&.info( "worker_starting worker_id=#{@worker_id} job_type_count=#{job_types.length} " \ "queues=#{queues.join(',')}", ) register(queues, job_types) poll_loop(queues, job_types) end |