feat(probe): public contract API + theme hosting + meta editing (item 7 B3)
This commit is contained in:
@@ -83,3 +83,56 @@ func TrafficSnapshot() (map[int64]Traffic, error) {
|
||||
}
|
||||
return st.AllTraffic()
|
||||
}
|
||||
|
||||
// MetaSnapshot is the B3 read port for display metadata: every agent's
|
||||
// probe_meta row, keyed by agent id. Agents without a row are absent;
|
||||
// callers substitute DefaultMeta.
|
||||
func MetaSnapshot() (map[int64]Meta, error) {
|
||||
st := Default()
|
||||
if st == nil {
|
||||
return map[int64]Meta{}, nil
|
||||
}
|
||||
return st.AllMeta()
|
||||
}
|
||||
|
||||
// MetaFor reads one agent's metadata row from the default store.
|
||||
// ok is false when the agent never reported (no row ensured yet).
|
||||
func MetaFor(agentID int64) (Meta, bool, error) {
|
||||
st := Default()
|
||||
if st == nil {
|
||||
return Meta{}, false, nil
|
||||
}
|
||||
return st.Meta(agentID)
|
||||
}
|
||||
|
||||
// SaveMeta persists one agent's metadata row (B3 edit surface).
|
||||
func SaveMeta(m Meta) error {
|
||||
st := Default()
|
||||
if st == nil {
|
||||
return nil
|
||||
}
|
||||
return st.UpsertMeta(m)
|
||||
}
|
||||
|
||||
// MetricHistory is the B3 read port for one agent's history window.
|
||||
// With no store the window is simply empty.
|
||||
func MetricHistory(agentID int64, sp Span) ([]MetricRow, error) {
|
||||
st := Default()
|
||||
if st == nil {
|
||||
return []MetricRow{}, nil
|
||||
}
|
||||
return st.MetricHistory(agentID, sp)
|
||||
}
|
||||
|
||||
// DeleteAgentData drops a removed agent's probe rows (B3 cleanup point
|
||||
// called from agent deletion). Best-effort: failures are logged and
|
||||
// swallowed, as a stale probe row must never block a panel operation.
|
||||
func DeleteAgentData(agentID int64) {
|
||||
st := Default()
|
||||
if st == nil {
|
||||
return
|
||||
}
|
||||
if err := st.DeleteAgentData(agentID); err != nil {
|
||||
logger.Warningf("probe: delete agent %d data: %v", agentID, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user