Class: Collavre::Orchestration::Scheduler
- Inherits:
-
Object
- Object
- Collavre::Orchestration::Scheduler
- Defined in:
- app/services/collavre/orchestration/scheduler.rb
Overview
Scheduler decides when to execute agent jobs based on resource availability.
Scheduling decisions:
-
:immediate - Execute now
-
:delayed - Execute after a delay (with :delay value)
-
:rejected - Do not execute (with :reason)
Resource checks:
-
Active jobs count (concurrency limit)
-
Daily token usage (quota)
-
Rate limiting (requests per minute)
Constant Summary collapse
- BACKOFF_DELAYS =
Default backoff delays
{ immediate: 0, linear: 30.seconds, exponential_base: 10.seconds }.freeze
Instance Method Summary collapse
-
#initialize(context, policy_resolver: nil) ⇒ Scheduler
constructor
A new instance of Scheduler.
-
#schedule(agents) ⇒ Array<Hash>
Schedule agents for execution.
Constructor Details
#initialize(context, policy_resolver: nil) ⇒ Scheduler
Returns a new instance of Scheduler.
25 26 27 28 |
# File 'app/services/collavre/orchestration/scheduler.rb', line 25 def initialize(context, policy_resolver: nil) @context = context @policy_resolver = policy_resolver || PolicyResolver.new(context) end |
Instance Method Details
#schedule(agents) ⇒ Array<Hash>
Schedule agents for execution
34 35 36 37 38 39 40 41 |
# File 'app/services/collavre/orchestration/scheduler.rb', line 34 def schedule(agents) topic_immediate_count = 0 agents.map do |agent| decision = evaluate(agent, topic_immediate_count: topic_immediate_count) topic_immediate_count += 1 if decision[:timing] == :immediate decision end end |