Documentation
¶
Overview ¶
Package events owns operator telemetry: append-only event records with free-form metadata keys, retention pruning, and filtered queries for GET /api/events. All writes run through one service; no other package touches the events tables directly.
Index ¶
- Constants
- type Entry
- type KeyFilter
- type KeyValue
- type Query
- type Service
- func (s *Service) Append(ctx context.Context, timestamp time.Time, severity int, message string, ...) error
- func (s *Service) Prune(ctx context.Context) error
- func (s *Service) Query(ctx context.Context, query Query) ([]Entry, error)
- func (s *Service) SetLogger(l *slog.Logger)
- func (s *Service) Start(ctx context.Context)
Constants ¶
const ( SeverityDebug = 0 SeverityInfo = 1 SeverityWarn = 2 SeverityError = 3 SeverityFatal = 4 )
Severity levels for event records.
const DefaultLimit = 50
DefaultLimit bounds parameterless queries.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"timestamp"`
Severity int `json:"severity"`
Message string `json:"message"`
Keys []KeyValue `json:"keys"`
}
Entry is one event record with its metadata keys.
type KeyFilter ¶
KeyFilter is one filter.<key>[=<value>] or exclude.<key>[=<value>] predicate. A nil Value checks key existence only.
type Query ¶
type Query struct {
Severity *int
ID *int64
Start *time.Time
End *time.Time
Filters []KeyFilter
Excludes []KeyFilter
Limit int
}
Query carries the GET /api/events parameters.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service persists and queries events on the events handle.
func New ¶
New builds a Service on the events handle. RetentionDays must be at least 1; construction fails otherwise so miswiring surfaces at startup.
func (*Service) Append ¶
func (s *Service) Append(ctx context.Context, timestamp time.Time, severity int, message string, keys map[string]string) error
Append persists one event with its metadata keys in one transaction.
func (*Service) Query ¶
Query runs a filtered event query. ID mode returns at most one entry. Otherwise severity/start/end narrow the record scan, inclusions resolve to record IDs in bounded chunks, exclusions drop rows in Go, and keys assemble per record. Limit defaults to DefaultLimit.