feat: add proxy and statistics features
This commit is contained in:
@ -156,6 +156,14 @@ func (g *Gateway) Tunnel(stream agentv1.AgentGateway_TunnelServer) error {
|
||||
case *agentv1.AgentMessage_FileResult:
|
||||
g.registry.ResolvePending(agentID, p.FileResult.CommandId, p.FileResult)
|
||||
|
||||
case *agentv1.AgentMessage_StatsSnapshot:
|
||||
g.registry.UpdateStats(agentID, p.StatsSnapshot)
|
||||
g.broker.Publish(broker.Event{
|
||||
Type: "stats.updated",
|
||||
AgentID: agentID,
|
||||
Payload: p.StatsSnapshot,
|
||||
})
|
||||
|
||||
case *agentv1.AgentMessage_UpdateCheckResult:
|
||||
res := p.UpdateCheckResult
|
||||
if res.Error != "" {
|
||||
|
||||
@ -22,6 +22,7 @@ type AgentState struct {
|
||||
Volumes []*agentv1.VolumeInfo
|
||||
Networks []*agentv1.NetworkInfo
|
||||
|
||||
Stats *agentv1.StatsSnapshot
|
||||
cmdCh chan *agentv1.ServerMessage
|
||||
pendingFiles map[string]chan *agentv1.FileResult
|
||||
pendingUpdates map[string]string // commandID → containerID
|
||||
@ -102,6 +103,15 @@ func (r *Registry) UpdateResources(id string, containers []*agentv1.ContainerInf
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Registry) UpdateStats(id string, stats *agentv1.StatsSnapshot) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
if s, ok := r.agents[id]; ok {
|
||||
s.Stats = stats
|
||||
s.LastSeenAt = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateAlias refreshes the alias for a live agent (called after an admin update).
|
||||
func (r *Registry) UpdateAlias(id, alias string) {
|
||||
r.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user