Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Type string `json:"type"` // "message", "read", etc.
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Body string `json:"body,omitempty"`
ID int64 `json:"id,omitempty"`
At string `json:"at,omitempty"`
}
Event is pushed to watchers when something happens.
type Handler ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages event subscriptions.
func (*Hub) OnlineAgentIDs ¶
OnlineAgentIDs returns the IDs of agents with active watchers.
func (*Hub) Unsubscribe ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter tracks per-agent send rates using a sliding window.
func NewRateLimiter ¶
func NewRateLimiter(limit int, window time.Duration) *RateLimiter
NewRateLimiter creates a rate limiter that allows limit sends per window.
func (*RateLimiter) Allow ¶
func (r *RateLimiter) Allow(agentID int64) bool
Allow checks if agentID can send. Returns true and records the event, or returns false if the limit is exceeded.
Click to show internal directories.
Click to hide internal directories.