Documentation
¶
Overview ¶
Package live provides in-process realtime dashboard event fan-out.
Index ¶
- Constants
- type Broker
- func (b *Broker) Close()
- func (b *Broker) Enabled() bool
- func (b *Broker) HasLiveSubscribers() bool
- func (b *Broker) Heartbeat() time.Duration
- func (b *Broker) LatestSeq() uint64
- func (b *Broker) PublishAuditEvent(eventType string, entry *auditlog.LogEntry)
- func (b *Broker) PublishUsageEvent(eventType string, entry *usage.UsageEntry)
- func (b *Broker) Subscribe(cursor uint64) *Subscription
- type Config
- type Event
- type Subscription
Constants ¶
const ( EventAuditStarted = auditlog.LiveEventAuditStarted EventAuditUpdated = auditlog.LiveEventAuditUpdated EventAuditStream = auditlog.LiveEventAuditStream EventAuditCompleted = auditlog.LiveEventAuditCompleted EventAuditFailed = auditlog.LiveEventAuditFailed EventAuditFlushed = auditlog.LiveEventAuditFlushed EventAuditRemoved = auditlog.LiveEventAuditRemoved EventUsageCompleted = usage.LiveEventUsageCompleted EventUsageFailed = usage.LiveEventUsageFailed EventUsageFlushed = usage.LiveEventUsageFlushed EventHeartbeat = "heartbeat" EventReset = "reset" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker stores a bounded replay window and fans live events out to subscribers.
func (*Broker) Close ¶
func (b *Broker) Close()
Close terminates all active subscribers and prevents future live events.
func (*Broker) HasLiveSubscribers ¶
HasLiveSubscribers reports whether any dashboard stream is currently connected. Publishers of high-frequency preview events use it to skip building payloads nobody would receive.
func (*Broker) PublishAuditEvent ¶
PublishAuditEvent publishes a compact audit log preview event. Connected subscribers receive the full preview, including any captured bodies; the copy retained for replay strips bodies (flagging them as captured so the dashboard hydrates them from the persisted entry) and is size-capped, so broker retention stays bounded regardless of request size.
func (*Broker) PublishUsageEvent ¶
func (b *Broker) PublishUsageEvent(eventType string, entry *usage.UsageEntry)
PublishUsageEvent publishes a compact usage log event. Cached usage entries are broadcast like any other so the dashboard can choose to surface or hide them via the "Hide cached requests" toggle on the Usage page.
func (*Broker) Subscribe ¶
func (b *Broker) Subscribe(cursor uint64) *Subscription
Subscribe registers a client and returns replay events after cursor.
type Config ¶
type Config struct {
Enabled bool
BufferSize int
ReplayLimit int
SubscriberBuffer int
Heartbeat time.Duration
}
Config controls the in-process live event broker.
type Event ¶
type Event struct {
Seq uint64 `json:"seq"`
Type string `json:"type"`
RequestID string `json:"request_id,omitempty"`
Timestamp time.Time `json:"timestamp"`
Data json.RawMessage `json:"data,omitempty"`
}
Event is the stable envelope sent over the live dashboard stream.
type Subscription ¶
type Subscription struct {
Replay []Event
Events <-chan Event
Reset bool
// contains filtered or unexported fields
}
Subscription is one live stream consumer.