github.com/yandex/pandora@v0.5.32/core/aggregator/test.go (about) 1 package aggregator 2 3 import ( 4 "context" 5 "sync" 6 7 "github.com/yandex/pandora/core" 8 ) 9 10 func NewTest() *Test { 11 return &Test{} 12 } 13 14 type Test struct { 15 lock sync.Mutex 16 samples []core.Sample 17 } 18 19 var _ core.Aggregator = (*Test)(nil) 20 21 func (t *Test) Run(ctx context.Context, _ core.AggregatorDeps) error { 22 <-ctx.Done() 23 return nil 24 } 25 26 func (t *Test) Report(s core.Sample) { 27 t.lock.Lock() 28 t.samples = append(t.samples, s) 29 t.lock.Unlock() 30 } 31 32 func (t *Test) GetSamples() []core.Sample { 33 t.lock.Lock() 34 s := t.samples 35 t.lock.Unlock() 36 return s 37 }