The Sessions page polls its list and its stats every 15s, the Usage page its clients, and each asked agent.Clients() only for each agent's id, name and icon. Clients() builds every agent (30+ constructors): 2.5 ms, 378 KB and 3411 allocations a call on the Windows box with discovery's real 2s look window, mostly os.Stat, filepath.Join and Getenv. On the real-account run (t69, 4 min) agent.All under the sessions handler was 22 MB of 210 MB allocated. agent.Looks keeps that id/name/shared-name/icon list for 30s, built again at once when the plugins' agents change (agentplug's set) or the Agents page's refresh (Rescan). A new omp or QwenPaw profile shows by its id for up to 30s. Nothing is kept in a test binary unless a test says, so tests that add an agent read it at once. The GUI's sessions list, stats, one session, markdown export, trash, manage and reads views, and usageapi.Clients, read Looks. Tests: TestLooksBuiltOnceAWhile — six asks build once, the list equals Clients(), a plugin agent switched on and off shows at once, Rescan builds again. Broken by hand (memo check made false): "six asks built the agents 6 times; want once". Run on the Windows box: go test ./internal/agent ./internal/gui ./internal/usageapi at the pre-rebase base0cc91af3d: usageapi ok, agent and gui with 38 reds. Those tests, run at8aae124b0with and without this change: the same 37 fail on both (#6068). TestLooks/TestPlugged/TestRescan ok and go vet ok at8aae124b0. mote (macOS) refused ssh all session, so no macOS run and no real-account measurement yet. Rebased on156861b3aafter the runs; its new commits touch library, plugin and site only.
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/proc"
|
|
)
|
|
|
|
// Rescan forgets what was found of the agents on this machine a while ago,
|
|
// so the next read of them looks again at once: the reader asked for it with
|
|
// the Agents page's refresh (#844), having just installed an agent, or
|
|
// removed one, or changed its settings outside magpie. What is read from an
|
|
// agent's files every time needs nothing forgotten; these are the answers
|
|
// kept for a while because asking was slow (the apps folder, wsl.exe, Alma's
|
|
// server), and where each command was found on PATH (proc.LookPath).
|
|
func Rescan() {
|
|
proc.Forget()
|
|
forgetLooks() // a profile made since shows by its name
|
|
|
|
// where updates come from is asked again, too: a version published
|
|
// after magpie started showed no update until the memo ran out (#4980)
|
|
latests.expireAll()
|
|
wslProbes.expireAll()
|
|
|
|
cursorLocalSeen.Lock()
|
|
cursorLocalSeen.at = time.Time{}
|
|
cursorLocalSeen.Unlock()
|
|
|
|
wsl.Lock()
|
|
wsl.at, wsl.runAt = time.Time{}, time.Time{}
|
|
// a running distro is asked again, and one that failed is retried now
|
|
// rather than in ten minutes
|
|
wsl.probed, wsl.failed = map[string]bool{}, map[string]time.Time{}
|
|
wsl.Unlock()
|
|
|
|
almaRead.Lock()
|
|
almaRead.at, almaRead.body = nil, nil
|
|
almaRead.gen++
|
|
almaRead.Unlock()
|
|
}
|