Module: RubynCode::Autonomous::TaskClaimer
- Defined in:
- lib/rubyn_code/autonomous/task_claimer.rb
Overview
Claims and prepares unclaimed tasks for agent execution. Uses optimistic locking to handle race conditions when multiple agents attempt to claim the same task concurrently.
Constant Summary collapse
- MAX_RETRIES =
3
Class Method Summary collapse
-
.call(task_manager:, agent_name:, max_retries: MAX_RETRIES) ⇒ Tasks::Task?
Finds the first ready (pending, unowned) task that hasn’t exceeded max retries, claims it for the given agent, and returns the updated Task.
Class Method Details
.call(task_manager:, agent_name:, max_retries: MAX_RETRIES) ⇒ Tasks::Task?
Finds the first ready (pending, unowned) task that hasn’t exceeded max retries, claims it for the given agent, and returns the updated Task. Returns nil if no work is available.
19 20 21 22 23 24 25 26 |
# File 'lib/rubyn_code/autonomous/task_claimer.rb', line 19 def self.call(task_manager:, agent_name:, max_retries: MAX_RETRIES) db = task_manager.db claim_next_pending_task(db, agent_name, max_retries) fetch_claimed_task(db, agent_name) rescue StandardError => e RubynCode.logger.warn("TaskClaimer: failed to claim task: #{e.}") if RubynCode.respond_to?(:logger) nil end |