Documentation
¶
Overview ¶
Package objtest builds a data-object storage directory for testing: a bucket holding logs objects, the index objects that describe them, and the tables of contents a metastore.Metastore resolves through.
Reach for objtest when a test needs section resolution to work, because the metastore, the section indexes and the stream IDs are all real.
Reach for github.com/grafana/loki/v4/pkg/dataobj/fixtures instead when a test only needs one object with a hand-laid section and no bucket. That is cheaper and lets the test state every row.
Index ¶
Constants ¶
const Tenant = "objtest"
Tenant is the tenant a Builder stores logs for. A Builder holds one tenant because the index Calculator accepts only single-tenant objects.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a bucket holding logs data objects and index data objects. Append logs with Builder.Append, then call Builder.Close to write the indexes that make them resolvable.
func NewBuilder ¶
NewBuilder creates a builder that can be used for accumulating logs.
func (*Builder) Close ¶
func (b *Builder) Close()
Close flushes all remaining data and writes the indexes that make it resolvable. It does nothing on a second call: indexing twice would register every section again and a query would then count every row twice.
func (*Builder) Flush ¶
Flush writes the buffered logs as one object, so the streams appended after it land in a different object. It does nothing when nothing is buffered.
func (*Builder) Location ¶
Location returns the location of index for b so they can be read. Data is not guaranteed to exist in the location until calling Builder.Close.
func (*Builder) Metastore ¶
func (b *Builder) Metastore() *metastore.ObjectMetastore
Metastore returns a metastore that resolves the builder's objects. Call it after Builder.Close, which writes the indexes it reads.
type Location ¶
type Location struct {
Bucket objstore.Bucket // Bucket where all data is stored.
IndexPrefix string // Prefix for index objects in the Bucket.
}
Location holds information about where objects for a Builder are stored. Location can be used to read data from a builder.
type Option ¶
type Option func(*builderOptions)
Option customizes a Builder.
func WithBufferSize ¶
WithBufferSize sets the size of the buffer the builder accumulates encoded data in before flushing it. Zero keeps the builder's default.
func WithMaxPageRows ¶
WithMaxPageRows caps the row count of an encoded page. Zero keeps the builder's default.
func WithTargetObjectSize ¶
WithTargetObjectSize targets the compressed, encoded data one object holds before Append flushes it and starts a new one, so a small value splits a corpus across many objects instead of the few the builder's default otherwise produces. Zero keeps the builder's default.
func WithTargetPageSize ¶
WithTargetPageSize targets the uncompressed data one encoded page holds. Zero keeps the builder's default.
func WithTargetSectionSize ¶
WithTargetSectionSize targets the uncompressed data one logs section holds, so a small value forces an object to hold several logs sections. Overflow goes to a new section rather than being refused, which is why it is a target and not a limit.
Zero keeps the builder's default, which is large enough that a test's worth of logs lands in one section.