Documentation
¶
Overview ¶
Package backlog provides shared backlog analytics types, constants, and algorithms used by both the Admin API and MCP server.
Index ¶
Constants ¶
const ( // MaxListLimit is the upper bound for list/query limit parameters. MaxListLimit = 1000 // DefaultTrendWindow is the default time window for backlog trend queries. DefaultTrendWindow = time.Hour // DefaultTrendStep is the default bucket step for backlog trend queries. DefaultTrendStep = 5 * time.Minute // MinTrendStep is the minimum allowed trend bucket step. MinTrendStep = time.Minute // MaxTrendStep is the maximum allowed trend bucket step. MaxTrendStep = time.Hour // MaxTrendWindow is the maximum allowed trend query window. MaxTrendWindow = 7 * 24 * time.Hour // MaxTrendSamples is the maximum number of trend samples returned per query. MaxTrendSamples = 20000 )
Shared constants for backlog analytics queries.
Variables ¶
var DefaultSummaryStates = []queue.State{ queue.StateQueued, queue.StateLeased, queue.StateDead, }
DefaultSummaryStates is the default set of queue states included in backlog summary queries when no explicit states are specified.
Functions ¶
func AgePercentileNearestRank ¶
AgePercentileNearestRank returns the value at the given percentile using nearest-rank interpolation. The input slice must be sorted in ascending order.
func ObserveAgeWindow ¶
func ObserveAgeWindow(ageSeconds int, windows *AgeWindows)
ObserveAgeWindow increments the appropriate age bucket in windows based on the given age in seconds.
Types ¶
type AgePercentiles ¶
AgePercentiles holds P50/P90/P99 age percentiles in seconds, computed from a sample of queued item ages.
func AgePercentilesFromSamples ¶
func AgePercentilesFromSamples(samples []int) (AgePercentiles, bool)
AgePercentilesFromSamples computes P50/P90/P99 from a slice of age-in-seconds samples. Returns false when samples is empty.
type AgeWindows ¶
type AgeWindows struct {
LE5M int `json:"le_5m"`
GT5MLE15M int `json:"gt_5m_le_15m"`
GT15MLE1H int `json:"gt_15m_le_1h"`
GT1HLE6H int `json:"gt_1h_le_6h"`
GT6H int `json:"gt_6h"`
}
AgeWindows counts items by age bucket: ≤5m, 5m–15m, 15m–1h, 1h–6h, >6h.
type StateScanSummary ¶
StateScanSummary reports how many items were scanned for a given queue state and whether the scan was truncated by the query limit.