github.com/yandex/pandora@v0.5.32/core/aggregator/netsample/aggregator.go (about) 1 package netsample 2 3 import ( 4 "context" 5 6 "github.com/yandex/pandora/core" 7 ) 8 9 //go:generate go run github.com/vektra/mockery/v2@v2.22.1 --inpackage --name=Aggregator --filename=mock_aggregator.go 10 11 type Aggregator interface { 12 Run(ctx context.Context, deps core.AggregatorDeps) error 13 Report(sample *Sample) 14 } 15 16 func WrapAggregator(a Aggregator) core.Aggregator { return &aggregatorWrapper{a} } 17 18 func UnwrapAggregator(a core.Aggregator) Aggregator { 19 switch a := a.(type) { 20 case *aggregatorWrapper: 21 return a.Aggregator 22 } 23 return &aggregatorUnwrapper{a} 24 } 25 26 type aggregatorWrapper struct{ Aggregator } 27 28 func (a *aggregatorWrapper) Report(s core.Sample) { a.Aggregator.Report(s.(*Sample)) } 29 30 type aggregatorUnwrapper struct{ core.Aggregator } 31 32 func (a *aggregatorUnwrapper) Report(s *Sample) { a.Aggregator.Report(s) }