refactor(worker/queue): split queue waker and picker, auto-wake on enqueue
Slice 3 of the worker state and queue consolidation refactor. - Add IQueueWaker / QueueWaker (singleton holding the wake semaphore). - Add IQueuePicker / QueuePicker; raw SQL UPDATE...RETURNING moves out of TaskRepository.GetNextQueuedAgentTaskAsync (deleted) and now also filters on blocked_by_task_id IS NULL and writes started_at on claim. - TaskStateService takes IQueueWaker directly; the Func<QueueService> indirection is gone. State transitions to Queued auto-wake the dispatcher. - QueueService waits via the shared waker and dispatches via the picker. - Drop explicit _queue.WakeQueue() calls in WorkerHub.QueuePlanningSubtasksAsync and ExternalMcpService.AddTask. The hub WakeQueue endpoint stays for diagnostics, delegating to _waker.Wake(). - Migrate tests; pre-existing flaky AppSettings/ExternalMcp tests untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
11
src/ClaudeDo.Worker/Queue/IQueueWaker.cs
Normal file
11
src/ClaudeDo.Worker/Queue/IQueueWaker.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace ClaudeDo.Worker.Queue;
|
||||
|
||||
/// <summary>
|
||||
/// Signals the queue dispatcher to check for new work. Wake() is non-blocking and
|
||||
/// idempotent — multiple calls before the dispatcher consumes the signal collapse
|
||||
/// into a single wake-up.
|
||||
/// </summary>
|
||||
public interface IQueueWaker
|
||||
{
|
||||
void Wake();
|
||||
}
|
||||
Reference in New Issue
Block a user