Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
Ticks []TickTimeline
}
Batch is a batch of completed tick timelines pushed to subscribers. Treat as read-only: subscribers must not mutate Ticks or its elements.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates per-tick span data and broadcasts it in batches to streaming subscribers. It is designed for a single writer (the tick loop) with concurrent reader subscriptions (gRPC stream handlers).
func NewCollector ¶
NewCollector creates a Collector that flushes every batchSize ticks.
func (*Collector) RecordSpan ¶
RecordSpan appends a span to the current tick.
func (*Collector) RecordTick ¶
RecordTick finalizes the current tick, appending a TickTimeline to the pending batch. When the batch reaches batchSize, it is flushed to all subscribers via non-blocking channel sends performed outside the lock.
func (*Collector) Reset ¶
func (c *Collector) Reset()
Reset clears all buffered data. Use after a world reset or snapshot restore.
func (*Collector) StartTick ¶
func (c *Collector) StartTick()
StartTick initializes span collection for a new tick. Call exactly once per tick before any RecordSpan calls.
func (*Collector) Subscribe ¶
Subscribe returns a channel that receives Batch values whenever the collector flushes. The caller must eventually call Unsubscribe to avoid leaking the channel.
func (*Collector) Unsubscribe ¶
Unsubscribe removes the given channel from the subscriber list. The channel is intentionally not closed: closing would make receives return zero values instead of blocking, breaking select/default patterns. Callers should select on ctx.Done() to detect stream termination.