Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMaxDepthExceeded = errors.New("maximum JSON nesting depth exceeded")
ErrMaxDepthExceeded is returned when the payload exceeds the maximum depth limit.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
MaxDepth int // Prevents Stack Overflow (Default: 32)
MaxPaths int // Prevents Cardinality Explosion (Default: 1000)
FlushInterval time.Duration // Interval for buffering writes to stats backend (Default: 100ms)
}
Config defines execution and limits for safety.
type PathStatsSnapshot ¶
PathStatsSnapshot represents the snapshot of a path's counters.
type PathUpdate ¶
PathUpdate represents an aggregated increment update for a path and type.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler is the entrypoint coordinator.
func NewSampler ¶
func NewSampler(backend StatsBackend, cfg Config) *Sampler
NewSampler initializes a new Sampler with a backend and configuration.
func (*Sampler) Close ¶
Close flushes any pending stats and shuts down the background flushing worker. It returns an error if the shutdown or final flush timed out.
func (*Sampler) DeleteSchema ¶ added in v0.2.0
DeleteSchema removes a schema ID and all its accumulated stats from local memory and deletes the schema's metrics from the persistent stats backend.
type SchemaNode ¶
type SchemaNode struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"` // "string", "number", "mixed", "null", "object", etc.
Required bool `json:"required"` // Evaluated against parent observation frequency
Probability map[string]float64 `json:"probability"` // E.g., {"string": 0.95, "number": 0.05}
Children map[string]*SchemaNode `json:"children,omitempty"`
}
SchemaNode represents a reconstructed node in the schema tree.
type StatsBackend ¶
type StatsBackend interface {
MapIncrementBy(ctx context.Context, key, field string, delta float64) (float64, error)
MapGetAll(ctx context.Context, key string) (map[string]string, error)
Delete(ctx context.Context, key string) error
}
StatsBackend represents the abstraction layer for stats storage. It matches Capacitor's MapIncrementBy, MapGetAll, and Delete methods, enabling implicit integration.