Documentation
¶
Overview ¶
Package observation provides an in-process, multi-subscriber feed for traffic observations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindMetrics ¶
BindMetrics registers observation feed counters with the given registry.
Types ¶
type Feed ¶
type Feed struct {
// contains filtered or unexported fields
}
Feed is an in-process, typed, multi-subscriber observation bus. Publishers call Publish (non-blocking); subscribers receive on their own goroutine via a buffered channel.
func (*Feed) Close ¶
func (f *Feed) Close()
Close unsubscribes all subscribers and waits for their goroutines to finish.
func (*Feed) Dropped ¶
Dropped returns the total number of observations dropped across all subscribers due to full buffers.
func (*Feed) Publish ¶
func (f *Feed) Publish(obs Observation)
Publish fans out an observation to all subscribers. Non-blocking: if a subscriber's buffer is full the observation is dropped and the drop counter increments. The publisher's goroutine is never stalled.
func (*Feed) Subscribe ¶
func (f *Feed) Subscribe(name string, fn func(Observation)) int
Subscribe registers a handler that will be called for every published observation on its own goroutine. Returns an ID for Unsubscribe.
func (*Feed) Unsubscribe ¶
Unsubscribe removes the subscriber with the given ID and waits for its goroutine to exit. The data channel is left open so a concurrent Publish holding a stale snapshot does not panic on a closed channel.