window

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MaxWindowSize = 100

MaxWindowSize is the upper bound for WindowSize.

View Source
const SetWindow = "window"

SetWindow is the set name for window storage.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, c deleteClient, req Request, src queries.Source) error

Delete removes the stored window data for the given entity. The key is deterministic from (Name, Ref, source values, GroupBy).

Types

type Request

type Request struct {
	Name           string        // variable name
	Namespace      string        // FrogoDB namespace
	Ref            string        // source key for entity reference
	GroupBy        []string      // grouping fields
	Value          string        // source key for numeric value
	WindowSize     int           // last N events (max 100)
	Fields         queries.Field // which functions to compute
	PercentileP    float64       // for percentile (0-1)
	EventID        string        // current event ID (for dedup)
	TTL            time.Duration // REQUIRED. Expiration for window records.
	IncludeCurrent bool
}

Request describes a sliding window aggregation query.

func (Request) Validate

func (r Request) Validate() error

Validate checks that required fields are set.

type Result

type Result struct {
	Count      int64
	Sum        float64
	Min        float64
	Max        float64
	Avg        float64
	STD        float64
	Percentile float64
	Values     []float64 // the raw window values (for debugging)
}

Result holds the outcome of a sliding window aggregation.

func Execute

func Execute(ctx context.Context, c operateClient, req Request, src queries.Source) (Result, error)

Execute writes the current event value and reads the window aggregation. The order of write vs read is controlled by IncludeCurrent.

func Read

func Read(ctx context.Context, c operateClient, req Request, src queries.Source) (Result, error)

Read performs a read-only window query without writing the current event.

Jump to

Keyboard shortcuts

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