Help us shape the future of Go! Take the 2026 Go Developer Survey

ewmaparams

package
v1.0.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ewmaparams is the one reading of WIN_EWMA's params, shared by the window factory (internal/processing/window) and predict (internal/descriptor) so both refuse the same request with the same message. It decides what a request MEANS and never smooths a value.

The smoothing factor is given as exactly one of `alpha` or `decay` (alpha = 1 − decay). A decay is converted through the EXACT decimal of its JSON literal: `decay: 0.7` yields the double nearest 3/10, which is the double of the literal `alpha: 0.3` — never the float64 subtraction 1.0 − 0.7 (0.30000000000000004).

Leaf: stdlib + the public errors package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	Alpha *float64        `json:"alpha"`
	Decay json.RawMessage `json:"decay"`
}

Params is the typed wire shape of WIN_EWMA's params. Decay stays a raw literal so its exact decimal value survives the decode.

type Refusal

type Refusal struct {
	Message string
	Details map[string]any
}

Refusal is one violated rule: Message is the operator-neutral sentence (callers prefix their own context) and Details the offending values.

func Resolve

func Resolve(raw json.RawMessage) (float64, *Refusal)

Resolve reads raw params and returns the effective alpha, or the first rule the params break.

func (*Refusal) Coded

func (r *Refusal) Coded() *errors.CodedError

Coded returns the refusal as a PULSE_WINDOW_INVALID error with the runtime prefix — the factory's refusal, predict's code (the window family's one code, internal/windowparams).

func (*Refusal) Error

func (r *Refusal) Error() string

Error renders the refusal for callers that wrap it.

Jump to

Keyboard shortcuts

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