Documentation
¶
Overview ¶
Package wqueue provides a write queue implementation for managing data shards.
Index ¶
- Variables
- type Opts
- type Queue
- func (q *Queue[S, O]) ActiveSeries() *storage.ActiveSeries
- func (q *Queue[S, O]) Close() error
- func (q *Queue[S, O]) Drop() (err error)
- func (q *Queue[S, O]) GetNodes(shardID common.ShardID) []string
- func (q *Queue[S, O]) GetOrCreateShard(shardID common.ShardID) (*Shard[S], error)
- func (q *Queue[S, O]) GetTimeRange(ts time.Time) timestamp.TimeRange
- func (q *Queue[S, O]) SubQueues() []S
- func (q *Queue[S, O]) UpdateOptions(resourceOpts *commonv1.ResourceOpts)
- type Shard
- type SubQueue
- type SubQueueCreator
- type SubQueueCreatorWithLease
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownShard indicates that the shard is not found. ErrUnknownShard = errors.New("unknown shard") )
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts[S SubQueue, O any] struct { SubQueueCreator SubQueueCreator[S, O] SubQueueCreatorWithLease SubQueueCreatorWithLease[S, O] RootLeaseFactory storage.RootLeaseFactory GetNodes func(common.ShardID) []string Collect func(S) Metrics storage.Metrics MetricsFactory observability.Factory ActiveSeriesFactory observability.Factory Option O Group string Location string SegmentInterval storage.IntervalRule ShardNum uint32 }
Opts contains configuration options for creating a queue.
type Queue ¶
Queue represents a write queue that manages multiple shards.
func (*Queue[S, O]) ActiveSeries ¶ added in v0.12.0
func (q *Queue[S, O]) ActiveSeries() *storage.ActiveSeries
ActiveSeries returns the active series tracker, or nil when Opts.ActiveSeriesFactory is not set.
func (*Queue[S, O]) Drop ¶ added in v0.10.0
Drop closes the queue and removes all data files from disk.
func (*Queue[S, O]) GetOrCreateShard ¶
GetOrCreateShard gets or creates a shard with the given ShardID. Existing shards are read under a shared lock; creation holds an exclusive lock.
func (*Queue[S, O]) GetTimeRange ¶
GetTimeRange returns a valid time range based on an input timestamp. It uses the Queue's SegmentInterval to generate the time range.
func (*Queue[S, O]) SubQueues ¶ added in v0.10.0
func (q *Queue[S, O]) SubQueues() []S
SubQueues returns sub-queues from all shards in the queue.
func (*Queue[S, O]) UpdateOptions ¶
func (q *Queue[S, O]) UpdateOptions(resourceOpts *commonv1.ResourceOpts)
UpdateOptions updates the queue options with new resource options.
type Shard ¶
type Shard[S SubQueue] struct { // contains filtered or unexported fields }
Shard represents a data shard containing a sub-queue and associated metadata.
type SubQueueCreator ¶
type SubQueueCreator[S SubQueue, O any] func(fileSystem fs.FileSystem, root string, position common.Position, l *logger.Logger, option O, metrics any, group string, shardID common.ShardID, getNodes func() []string) (S, error)
SubQueueCreator is a function type that creates a sub-queue with the given parameters.
type SubQueueCreatorWithLease ¶ added in v0.12.0
type SubQueueCreatorWithLease[S SubQueue, O any] func(fileSystem fs.FileSystem, root string, position common.Position, l *logger.Logger, option O, metrics any, group string, shardID common.ShardID, getNodes func() []string, lease storage.RootLease) (S, error)
SubQueueCreatorWithLease is the ownership-aware sub-queue constructor.