Documentation
¶
Overview ¶
Package monitor provides a real-time web dashboard for a DDS participant. It embeds a single-page HTML UI (Server-Sent Events) and exposes an HTTP server that streams DDS samples and participant metrics to any browser.
Usage:
p, _ := rtps.New(dds.Domain(0))
mon, _ := monitor.New(p, monitor.Options{Addr: ":8080"})
defer mon.Close()
// browse http://localhost:8080
Index ¶
- type Monitor
- func (m *Monitor) Addr() string
- func (m *Monitor) Close() error
- func (m *Monitor) Publish(s dds.Sample)
- func (m *Monitor) PublishSafetyEvent(e safety.SafetyEvent)
- func (m *Monitor) RegisterSafetyMetrics(p safety.SafetyMetricsProvider)
- func (m *Monitor) RegisterTSNHealth(name string, ht *tsn.HealthTracker)
- func (m *Monitor) WatchSafety(events <-chan safety.SafetyEvent)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor wraps a dds.Participant and serves a real-time web dashboard.
func New ¶
func New(p dds.Participant, opts Options) (*Monitor, error)
New creates a Monitor wrapping p and starts the HTTP server. The caller must call Close() to release the HTTP listener.
func (*Monitor) Addr ¶
Addr returns the address the HTTP server is listening on (useful when Addr was ":0" to let the OS pick a port).
func (*Monitor) Publish ¶
Publish emits a sample event to all connected browser clients. Call this whenever a sample is written or received that should appear in the dashboard.
func (*Monitor) PublishSafetyEvent ¶ added in v0.12.1
func (m *Monitor) PublishSafetyEvent(e safety.SafetyEvent)
PublishSafetyEvent broadcasts a safety violation event to all connected SSE clients.
func (*Monitor) RegisterSafetyMetrics ¶ added in v0.13.0
func (m *Monitor) RegisterSafetyMetrics(p safety.SafetyMetricsProvider)
RegisterSafetyMetrics adds p to the set of safety metrics providers whose snapshots are periodically broadcast as "safety_metrics" SSE events. May be called after New returns.
func (*Monitor) RegisterTSNHealth ¶ added in v0.13.0
func (m *Monitor) RegisterTSNHealth(name string, ht *tsn.HealthTracker)
RegisterTSNHealth registers a HealthTracker under name. Its health snapshot is periodically broadcast as a "tsn_health" SSE event and served at /api/tsn. May be called after New returns.
func (*Monitor) WatchSafety ¶ added in v0.12.1
func (m *Monitor) WatchSafety(events <-chan safety.SafetyEvent)
WatchSafety starts a goroutine that reads from events and calls PublishSafetyEvent for each one. It stops when the monitor is closed or the channel is closed. Intended to be wired to E2ESubscriber.SafetyEvents().