30 lines
992 B
Go
30 lines
992 B
Go
package tseries
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/tech/sendico/pkg/db/repository/builder"
|
|
rdecoder "github.com/tech/sendico/pkg/db/repository/decoder"
|
|
tspoint "github.com/tech/sendico/pkg/db/tseries/point"
|
|
)
|
|
|
|
// TimeSeries[T] abstracts a Mongo time-series “bucket” of documents of type T.
|
|
type TimeSeries interface {
|
|
// Aggregate runs an aggregation pipeline on the time-series
|
|
Aggregate(ctx context.Context, builder builder.Pipeline, decoder rdecoder.DecodingFunc) error
|
|
// Insert adds a single point into the series.
|
|
Insert(ctx context.Context, point tspoint.TimePoint) error
|
|
// InsertMany adds multiple points in one bulk operation.
|
|
InsertMany(ctx context.Context, points []tspoint.TimePoint) error
|
|
|
|
// Query fetches all points whose timeField lies in [from, to).
|
|
// The 'filter' param is an optional Mongo-style query on meta or other fields.
|
|
Query(
|
|
ctx context.Context,
|
|
decoder rdecoder.DecodingFunc,
|
|
filter builder.Query,
|
|
from, to *time.Time,
|
|
) error
|
|
}
|