Skip to content

Commit

Permalink
chore(dataobj): add skeleton for public API to build objects
Browse files Browse the repository at this point in the history
  • Loading branch information
rfratto committed Jan 13, 2025
1 parent 068f81d commit 2cb4946
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions pkg/dataobj/dataobj.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Package dataobj holds utilities for working with data objects.
package dataobj

import (
"context"

"github.com/thanos-io/objstore"

"github.com/grafana/loki/pkg/push"
)

// BuilderConfig configures a data object [Builder].
type BuilderConfig struct{}

// A Builder builds data objects from a set of incoming log data. Log data is
// appended to a builder by calling [Builder.Append]. Buffered log data is
// flushed manually by calling [Builder.Flush].
//
// Methods on Builder are not goroutine-safe; callers are responsible for
// synchronizing calls.
type Builder struct{}

// NewBuilder creates a new Builder which stores data objects for the specified
// tenant in a bucket.
func NewBuilder(cfg BuilderConfig, bucket objstore.Bucket, tenantID string) *Builder {
// TODO(rfratto): implement
_ = cfg
_ = bucket
_ = tenantID
return &Builder{}
}

// Append buffers an entry to be written to a data object. If the Builder is
// full, Append returns false without appending the entry.
//
// Once a Builder is full, call [Builder.Flush] to flush the buffered data,
// then call Append again with the same entry.
func (b *Builder) Append(entry push.PushRequest) bool {
// TODO(rfratto): implement
_ = entry
return true
}

// Flush flushes all buffered data to object storage. Calling Flush be result
// in a no-op if there is no buffered data to flush.
func (b *Builder) Flush(ctx context.Context) error {
// TODO(rfratto): implement
_ = ctx
return nil
}

0 comments on commit 2cb4946

Please sign in to comment.