autopilot/manager: add QueryHeuristics
Proxies a query request to the active agent.
This commit is contained in:
parent
6c556fd92a
commit
8f54a2bd6f
@ -1,6 +1,7 @@
|
||||
package autopilot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
@ -267,3 +268,22 @@ func (m *Manager) StopAgent() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryHeuristics queries the active autopilot agent for node scores.
|
||||
func (m *Manager) QueryHeuristics(nodes []NodeID) (HeuristicScores, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
// Not active, so we can return early.
|
||||
if m.pilot == nil {
|
||||
return nil, fmt.Errorf("autopilot not active")
|
||||
}
|
||||
|
||||
n := make(map[NodeID]struct{})
|
||||
for _, node := range nodes {
|
||||
n[node] = struct{}{}
|
||||
}
|
||||
|
||||
log.Debugf("Querying heuristics for %d nodes", len(n))
|
||||
return m.pilot.queryHeuristics(n)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user