Documentation
¶
Index ¶
- func TimeseriesMergeFuncFromBytes(unmarshaler timeseries.UnmarshalerFunc) func(*Accumulator, []byte, int) error
- type Accumulator
- func (a *Accumulator) GetGeneric() any
- func (a *Accumulator) GetGenericUnsafe() any
- func (a *Accumulator) GetTSData() timeseries.Timeseries
- func (a *Accumulator) Lock()
- func (a *Accumulator) SetGeneric(data any)
- func (a *Accumulator) SetGenericUnsafe(data any)
- func (a *Accumulator) SetTSData(data timeseries.Timeseries)
- func (a *Accumulator) Unlock()
- type MarshallerPtr
- type MergeFunc
- func TimeseriesMergeFunc(unmarshaler timeseries.UnmarshalerFunc) MergeFunc
- func TimeseriesMergeFuncTolerant(unmarshaler timeseries.UnmarshalerFunc, toleranceNanos int64) MergeFunc
- func TimeseriesMergeFuncWithStrategy(unmarshaler timeseries.UnmarshalerFunc, strategy int) MergeFunc
- func TimeseriesMergeFuncWithStrategyTolerant(unmarshaler timeseries.UnmarshalerFunc, strategy int, toleranceNanos int64) MergeFunc
- type MergeFuncLookup
- type MergeFuncPair
- type Mergeable
- type RespondFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TimeseriesMergeFuncFromBytes ¶
func TimeseriesMergeFuncFromBytes(unmarshaler timeseries.UnmarshalerFunc) func(*Accumulator, []byte, int) error
TimeseriesMergeFuncFromBytes creates a MergeFunc that accepts []byte and unmarshals it This is a convenience function for call sites that still have []byte
Types ¶
type Accumulator ¶
type Accumulator struct {
MergeCount int // number of datasets merged (for avg finalization)
// contains filtered or unexported fields
}
Accumulator is a thread-safe accumulator for merging data It can hold either timeseries.Timeseries or any other mergeable type
func (*Accumulator) GetGeneric ¶
func (a *Accumulator) GetGeneric() any
GetGeneric returns the accumulated generic data (thread-safe)
func (*Accumulator) GetGenericUnsafe ¶
func (a *Accumulator) GetGenericUnsafe() any
GetGenericUnsafe returns the generic data without locking (caller must hold lock)
func (*Accumulator) GetTSData ¶
func (a *Accumulator) GetTSData() timeseries.Timeseries
GetTSData returns the accumulated timeseries data (thread-safe)
func (*Accumulator) Lock ¶
func (a *Accumulator) Lock()
Lock locks the accumulator's mutex (for use by merge functions)
func (*Accumulator) SetGeneric ¶
func (a *Accumulator) SetGeneric(data any)
SetGeneric sets the accumulated generic data (thread-safe)
func (*Accumulator) SetGenericUnsafe ¶
func (a *Accumulator) SetGenericUnsafe(data any)
SetGenericUnsafe sets the generic data without locking (caller must hold lock)
func (*Accumulator) SetTSData ¶
func (a *Accumulator) SetTSData(data timeseries.Timeseries)
SetTSData sets the accumulated timeseries data (thread-safe)
func (*Accumulator) Unlock ¶
func (a *Accumulator) Unlock()
Unlock unlocks the accumulator's mutex (for use by merge functions)
type MarshallerPtr ¶
MarshallerPtr represents pointer types that can start marshaling with an envelope
type MergeFunc ¶
type MergeFunc func(*Accumulator, any, int) error
MergeFunc is a function type that merges unmarshaled data into an accumulator It takes the accumulator, unmarshaled data (either timeseries.Timeseries or a type conforming to Mergeable[T]), and index, and returns an error
func TimeseriesMergeFunc ¶
func TimeseriesMergeFunc(unmarshaler timeseries.UnmarshalerFunc) MergeFunc
TimeseriesMergeFunc creates a MergeFunc for timeseries data The returned function accepts a timeseries.Timeseries and merges it into the accumulator
func TimeseriesMergeFuncTolerant ¶ added in v2.0.2
func TimeseriesMergeFuncTolerant(unmarshaler timeseries.UnmarshalerFunc, toleranceNanos int64) MergeFunc
TimeseriesMergeFuncTolerant is TimeseriesMergeFunc with an opt-in dedup tolerance window. toleranceNanos == 0 preserves legacy exact-epoch dedup.
func TimeseriesMergeFuncWithStrategy ¶ added in v2.0.2
func TimeseriesMergeFuncWithStrategy(unmarshaler timeseries.UnmarshalerFunc, strategy int) MergeFunc
TimeseriesMergeFuncWithStrategy creates a MergeFunc that uses a merge strategy (as an int matching dataset.MergeStrategy) to aggregate values from matching series across backends, rather than deduplicating.
For avg, pairwise merges accumulate sums; the final division happens in the RespondFunc via FinalizeAvg on the accumulator.
func TimeseriesMergeFuncWithStrategyTolerant ¶ added in v2.0.2
func TimeseriesMergeFuncWithStrategyTolerant(unmarshaler timeseries.UnmarshalerFunc, strategy int, toleranceNanos int64, ) MergeFunc
TimeseriesMergeFuncWithStrategyTolerant extends TimeseriesMergeFuncWithStrategy with an opt-in dedup tolerance window (nanoseconds). When toleranceNanos > 0, the underlying timeseries type, if it supports optsMerger, collapses near-duplicate samples whose epochs differ by no more than the window.
type MergeFuncLookup ¶
type MergeFuncLookup map[string]*MergeFuncPair
type MergeFuncPair ¶
type MergeFuncPair struct {
Merge MergeFunc
Respond RespondFunc
}
type Mergeable ¶
type Mergeable[T any] interface { *T Merge(...*T) }
Mergeable represents types that can merge with other instances of the same type
type RespondFunc ¶
type RespondFunc func(http.ResponseWriter, *http.Request, *Accumulator, int)
RespondFunc is a function type that writes the merged result to the response writer It takes the response writer, request, accumulator, and status code
func TimeseriesRespondFunc ¶
func TimeseriesRespondFunc(marshaler timeseries.MarshalWriterFunc, requestOptions *timeseries.RequestOptions) RespondFunc
TimeseriesRespondFunc creates a RespondFunc for timeseries data It writes the merged timeseries using the marshaler
func TimeseriesRespondFuncWithStrategy ¶ added in v2.0.2
func TimeseriesRespondFuncWithStrategy(marshaler timeseries.MarshalWriterFunc, requestOptions *timeseries.RequestOptions, strategy int) RespondFunc
TimeseriesRespondFuncWithStrategy creates a RespondFunc that finalizes avg aggregation before writing the response.