-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dataobj): add skeleton for public API to build objects
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |