Remove separate tracking structures and store protocol data directly on nodes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-28 22:15:54 -08:00
parent 41000bd4a0
commit fc5b36cd1c
8 changed files with 484 additions and 709 deletions

View File

@@ -6,6 +6,7 @@ import (
"net"
"sort"
"strings"
"time"
"github.com/fvbommel/sortorder"
"go.jetify.com/typeid"
@@ -149,6 +150,11 @@ type Node struct {
DanteRx []*DantePeer `json:"dante_rx,omitempty"`
Unreachable bool `json:"unreachable,omitempty"`
pollTrigger chan struct{}
multicastLastSeen map[string]time.Time
artnetLastSeen time.Time
sacnLastSeen time.Time
danteLastSeen time.Time
}
type DantePeer struct {
@@ -157,6 +163,24 @@ type DantePeer struct {
Status map[string]string `json:"status,omitempty"`
}
func (p *DantePeer) MarshalJSON() ([]byte, error) {
type peerJSON struct {
Node *Node `json:"node"`
Channels []string `json:"channels,omitempty"`
Status map[string]string `json:"status,omitempty"`
}
nodeRef := &Node{
TypeID: p.Node.TypeID,
Names: p.Node.Names,
Interfaces: p.Node.Interfaces,
}
return json.Marshal(peerJSON{
Node: nodeRef,
Channels: p.Channels,
Status: p.Status,
})
}
func (n *Node) WithInterface(ifaceKey string) *Node {
if ifaceKey == "" {
return n