Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cmd/agentsview/archive_write_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ func newArchivePushUnwatchedPoller(
return hooks.newUnwatchedPoller(ctx, engine)
}
ticker := time.NewTicker(unwatchedPollInterval)
return newUnwatchedPollCoordinatorWithTicks(
return newUnwatchedPollCoordinatorWithSchedule(
ctx, engine, ticker.C, ticker.Stop, func(work func()) { work() }, nil,
unwatchedPollInterval,
)
}

Expand Down Expand Up @@ -155,10 +156,16 @@ func archivePushWatchWatcherOptions(
return loop.NotifyCoverageDegraded(roots)
},
OnPollingRequired: func(obligation syncpkg.PollingObligation) error {
scopes := make([]pollingScope, 0, len(obligation.Scopes))
for _, scope := range obligation.Scopes {
scopes = append(scopes, pollingScope{
Agent: parser.AgentType(scope.Agent), Root: scope.SyncDir,
CoverageKey: scope.CoverageKey,
})
}
return poller.AddObligation(pollingObligation{
Key: obligation.Key,
Roots: obligation.Roots,
Probe: obligation.Probe,
Key: obligation.Key, Roots: obligation.Roots, Probe: obligation.Probe,
NonBlockingProbe: obligation.NonBlockingProbe, Scopes: scopes,
})
},
OnPollingReleased: poller.RemoveObligation,
Expand All @@ -172,7 +179,7 @@ func archivePushWatchBatchCallback(
) syncpkg.WatchCallback {
return func(callbackCtx context.Context, batch syncpkg.WatchBatch) error {
scope := func() watchRecoveryScope {
return probeWatchRecoveryScope(appCfg)
return probeWatchRecoveryScopeWithOwner(appCfg, engine)
}
if err := syncWatchBatch(callbackCtx, engine, batch, scope); err != nil {
return err
Expand Down
13 changes: 13 additions & 0 deletions cmd/agentsview/archive_write_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,19 @@ type pushWatchOwnerCase struct {
run func(context.Context, *archivePushWatchHooks) error
}

func TestStartArchivePushWatcherWithoutLocalEngine(t *testing.T) {
root := t.TempDir()
cfg := config.Config{AgentDirs: map[parser.AgentType][]string{
parser.AgentOpenCode: {root},
}}
stop, open, _ := startArchivePushWatcher(
nil, cfg, nil, func(context.Context, syncpkg.WatchBatch) error { return nil },
syncpkg.WatcherOptions{},
)
open()
stop()
}

func pushWatchOwnerCases(t *testing.T) []pushWatchOwnerCase {
t.Helper()
// Keep SQLite setup outside the timed owner goroutines so channel deadlines
Expand Down
Loading