api

package
v0.0.0-...-8979337 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

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 Handler struct {
	Store    store.Store
	DataDir  string
	Events   *Hub
	Notifier *notify.Notifier // nil means email notifications disabled
	Limiter  *RateLimiter     // nil disables rate limiting
}

func (*Handler) Handle

func (h *Handler) Handle(sess ssh.Session)

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub manages event subscriptions.

func NewHub

func NewHub() *Hub

func (*Hub) Notify

func (h *Hub) Notify(agentIDs []int64, evt Event)

Notify sends an event to all watchers of the given agent IDs.

func (*Hub) OnlineAgentIDs

func (h *Hub) OnlineAgentIDs() []int64

OnlineAgentIDs returns the IDs of agents with active watchers.

func (*Hub) Subscribe

func (h *Hub) Subscribe(agentID int64) chan Event

func (*Hub) Unsubscribe

func (h *Hub) Unsubscribe(agentID int64, ch chan Event)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL