Documentation
¶
Overview ¶
Package events provides protocol event pub/sub and webhook notifications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event struct {
ID string `json:"id"`
Type EventType `json:"type"`
Protocol string `json:"protocol"`
Timestamp time.Time `json:"timestamp"`
Data any `json:"data"`
}
Event represents a protocol event.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event pub/sub.
func (*EventBus) AddWebhook ¶
AddWebhook registers a webhook.
func (*EventBus) Replay ¶
func (eb *EventBus) Replay(filter *FilterRule) []*Event
Replay replays historical events.
func (*EventBus) Unsubscribe ¶
Unsubscribe removes a subscriber.
type FilterRule ¶
type FilterRule struct {
Types []EventType `json:"types,omitempty"`
Protocols []string `json:"protocols,omitempty"`
}
FilterRule defines an event filter.
func (*FilterRule) Match ¶
func (f *FilterRule) Match(e *Event) bool
Match checks if an event matches the filter.
type Webhook ¶
type Webhook struct {
URL string `json:"url"`
Filter FilterRule `json:"filter"`
}
Webhook represents a webhook endpoint.
Click to show internal directories.
Click to hide internal directories.