30 lines
802 B
Go
30 lines
802 B
Go
package models
|
|
|
|
import "sync"
|
|
|
|
type Device struct {
|
|
DeviceID string `json:"device_id"`
|
|
Hostname string `json:"hostname,omitempty"`
|
|
IP string `json:"ip"`
|
|
AgentPort int `json:"agent_port"`
|
|
MediaPort int `json:"media_port"`
|
|
DeviceName string `json:"device_name"`
|
|
Version string `json:"version"`
|
|
GitSha string `json:"git_sha"`
|
|
UptimeSec int64 `json:"uptime_sec,omitempty"`
|
|
LastSeenMs int64 `json:"last_seen_ms"`
|
|
Online bool `json:"online"`
|
|
Graphs interface{} `json:"graphs,omitempty"` // 摘要或详情
|
|
}
|
|
|
|
type DeviceRegistry struct {
|
|
Mu sync.RWMutex
|
|
Devices map[string]*Device
|
|
}
|
|
|
|
func NewDeviceRegistry() *DeviceRegistry {
|
|
return &DeviceRegistry{
|
|
Devices: make(map[string]*Device),
|
|
}
|
|
}
|