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:
24
types.go
24
types.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user