feat(work): orchestrate dry-run dispatch persistence

This commit is contained in:
m
2026-08-22 12:13:35 +03:00
parent fa62322ed2
commit 7f82240a8f
5 changed files with 107 additions and 2 deletions
@@ -0,0 +1,29 @@
package application
import (
"context"
"time"
"git.cin.su/m/Assistant/contracts/work"
"git.cin.su/m/Assistant/modules/work/domain"
"git.cin.su/m/Assistant/modules/work/ports"
)
func ExecuteDryRunDispatch(ctx context.Context, store ports.ExecutionStore, intent work.AgentDispatchIntent, workerID string, token work.AgentFencingToken, now time.Time, ttl time.Duration) (work.DryRunDispatch, error) {
dispatch, err := domain.BuildDryRunDispatch(intent, workerID, token, now, ttl)
if err != nil {
return work.DryRunDispatch{}, err
}
if err := store.SaveDispatchIntent(ctx, dispatch.Intent); err != nil {
return work.DryRunDispatch{}, err
}
if err := store.SaveAgentLease(ctx, dispatch.Lease); err != nil {
return work.DryRunDispatch{}, err
}
for _, callback := range dispatch.Callbacks {
if err := store.AcceptAgentCallback(ctx, callback); err != nil {
return work.DryRunDispatch{}, err
}
}
return dispatch, nil
}
+13
View File
@@ -0,0 +1,13 @@
package ports
import (
"context"
"git.cin.su/m/Assistant/contracts/work"
)
type ExecutionStore interface {
SaveDispatchIntent(context.Context, work.AgentDispatchIntent) error
SaveAgentLease(context.Context, work.AgentLease) error
AcceptAgentCallback(context.Context, work.AgentCallback) error
}