merge

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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 {
	// 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 NewAccumulator

func NewAccumulator() *Accumulator

NewAccumulator returns a new Accumulator

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

type MarshallerPtr[T any] interface {
	*T
	StartMarshal(w io.Writer, httpStatus int)
}

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

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

Jump to

Keyboard shortcuts

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