sse

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sse provides Server-Sent Events support for real-time key change notifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	Enabled() bool
	FilterKeysForRequest(r *http.Request, keys []string) []string
}

AuthProvider defines the interface for auth operations needed by SSE.

type Event

type Event struct {
	Key       string           `json:"key"`
	Action    enum.AuditAction `json:"action"`
	Timestamp string           `json:"timestamp"`
}

Event represents a key change event sent to subscribers.

type Service

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

Service handles SSE subscriptions for key change events.

func New

func New(auth AuthProvider) *Service

New creates a new SSE service.

func (*Service) Publish

func (s *Service) Publish(key string, action enum.AuditAction)

Publish sends a key change event to all matching subscribers. It publishes to the exact key topic and all prefix topics.

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for SSE subscriptions. Extends write deadline to allow long-lived streaming connections.

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the SSE server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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