observer

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package observer turns the engine's ObserverEvent callback into a loopback-served SSE stream — the SHN Kit flow inspector's data source. A ring buffer (last bufSize events) gives late/reconnecting subscribers replay via Last-Event-ID; live delivery is per-subscriber buffered and LOSSY under backpressure (a slow consumer misses events and re-syncs from the buffer on reconnect — the stream is diagnostic, never load-bearing for exchange correctness).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub fan-outs observer events to SSE subscribers. Zero value is not usable; call NewHub.

func NewHub

func NewHub() *Hub

func (*Hub) Emit

func (h *Hub) Emit(e engine.ObserverEvent)

Emit assigns the next seq, buffers, and fans out. Assign to engine.Config.Observer. NEVER drops an event for its payload: a payload snapshot is the raw bytes seen at the edge, and a malformed ingress body — the classic 400 case — is exactly the failure the inspector must show, but invalid JSON in a json.RawMessage makes json.Marshal fail. Non-JSON payloads are re-encoded as a JSON string and flagged in Detail.

func (*Hub) Handler

func (h *Hub) Handler() http.Handler

Handler serves GET /events (SSE) and GET /health.

Jump to

Keyboard shortcuts

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