Documentation
¶
Overview ¶
Package run provides the Worker-side RunCoordinator.
Coordinator manages Worker-local scheduling: concurrent slot limits, per-session serialization, debounce merging, cancellation, and active run tracking.
Coordinator MUST NOT depend on workspace, model, engine, artifact, event types, or NATS subjects.
Index ¶
- type Config
- type Coordinator
- func (c *Coordinator) Cancel(ctx context.Context, orgID, workerID uint, sessionID, runID string) error
- func (c *Coordinator) Close() error
- func (c *Coordinator) RegisterRun(sessionKey, runID, taskID string, cancel context.CancelFunc)
- func (c *Coordinator) Submit(ctx context.Context, submission RunSubmission) (RunOutcome, error)
- func (c *Coordinator) UnregisterRun(sessionKey string)
- type ExecuteFunc
- type RunOutcome
- type RunSubmission
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator manages Worker-local scheduling for agent runs.
func NewCoordinator ¶
func NewCoordinator(cfg Config, executeFunc ExecuteFunc) (*Coordinator, error)
NewCoordinator creates a new RunCoordinator.
func (*Coordinator) Cancel ¶
func (c *Coordinator) Cancel(ctx context.Context, orgID, workerID uint, sessionID, runID string) error
Cancel cancels the active run for the given session+runID.
func (*Coordinator) Close ¶
func (c *Coordinator) Close() error
Close shuts down the coordinator gracefully, waiting for all in-flight runs.
func (*Coordinator) RegisterRun ¶
func (c *Coordinator) RegisterRun(sessionKey, runID, taskID string, cancel context.CancelFunc)
RegisterRun records an active run for cancellation tracking.
func (*Coordinator) Submit ¶
func (c *Coordinator) Submit(ctx context.Context, submission RunSubmission) (RunOutcome, error)
Submit submits a run request. For session-keyed submissions, it goes through debounce merging; the caller blocks until the consolidated batch completes.
func (*Coordinator) UnregisterRun ¶
func (c *Coordinator) UnregisterRun(sessionKey string)
UnregisterRun removes a previously registered active run.
type ExecuteFunc ¶
type ExecuteFunc func( ctx context.Context, submission RunSubmission, ) (*agentrundomain.RunResult, error)
ExecuteFunc is the actual execution function injected by the command adapter.
type RunOutcome ¶
type RunOutcome struct {
Result *agentrundomain.RunResult
DeliverySeqs []uint64
}
RunOutcome is the result of executing a run (possibly merged from multiple submissions).
type RunSubmission ¶
type RunSubmission struct {
Request *agentrundomain.RunRequest
EventContext agentrun.EventContext
DeliverySeqs []uint64
// contains filtered or unexported fields
}
RunSubmission is a submitted run request with event context and delivery sequences.