pi-agent: Implement operation coordination
This commit is contained in:
@@ -32,6 +32,23 @@ func (m *progressiveDetectionModule) BeginTargetDetection() (app.Snapshot, <-cha
|
||||
}
|
||||
return cloneDetectionSnapshot(m.snapshot), m.streams[m.begins-1]
|
||||
}
|
||||
func (m *progressiveDetectionModule) StartOperation(intent app.Intent) app.OperationStream {
|
||||
initial, detection := m.BeginTargetDetection()
|
||||
updates := make(chan app.OperationUpdate, len(initial.Targets)+1)
|
||||
go func() {
|
||||
defer close(updates)
|
||||
for update := range detection {
|
||||
phase := app.OperationRunning
|
||||
status := app.OperationStatus{Kind: app.StatusProgress, Summary: "Checking Targets"}
|
||||
if update.Complete {
|
||||
phase = app.OperationSucceeded
|
||||
status = app.OperationStatus{Kind: app.StatusSuccess, Summary: "Target checks completed"}
|
||||
}
|
||||
updates <- app.OperationUpdate{Snapshot: update.Snapshot, Phase: phase, Status: status}
|
||||
}
|
||||
}()
|
||||
return app.OperationStream{Snapshot: initial, Updates: updates}
|
||||
}
|
||||
|
||||
func TestCompleteModelStreamsStartupAndRefreshByTargetWithoutMovingSelection(t *testing.T) {
|
||||
startup := make(chan app.TargetDetectionUpdate, 4)
|
||||
|
||||
Reference in New Issue
Block a user