client

package
v2.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMethodNotImplemented when any of the storage clients do not implement a method
	ErrMethodNotImplemented = errors.New("method is not implemented")
	// ErrStorageObjectNotFound when object storage does not have requested object
	ErrStorageObjectNotFound = errors.New("object not found in storage")
)
View Source
var FSEncoder = func(schema config.SchemaConfig, chk chunk.Chunk) string {

	key := schema.ExternalKey(chk.ChunkRef)
	if schema.VersionForChunk(chk.ChunkRef) > 11 {
		split := strings.LastIndexByte(key, '/')
		encodedTail := base64Encoder(key[split+1:])
		return strings.Join([]string{key[:split], encodedTail}, "/")

	}
	return base64Encoder(key)
}

Functions

This section is empty.

Types

type ChunkClientMetrics

type ChunkClientMetrics struct {
	// contains filtered or unexported fields
}

func NewChunkClientMetrics

func NewChunkClientMetrics(reg prometheus.Registerer) ChunkClientMetrics

type Client

type Client interface {
	Stop()
	PutChunks(ctx context.Context, chunks []chunk.Chunk) error
	GetChunks(ctx context.Context, chunks []chunk.Chunk) ([]chunk.Chunk, error)
	DeleteChunk(ctx context.Context, userID, chunkID string) error
	IsChunkNotFoundErr(err error) bool
}

Client is for storing and retrieving chunks.

func NewClient

func NewClient(store ObjectClient, encoder KeyEncoder, schema config.SchemaConfig) Client

NewClient wraps the provided ObjectClient with a chunk.Client implementation

func NewClientWithMaxParallel

func NewClientWithMaxParallel(store ObjectClient, encoder KeyEncoder, maxParallel int, schema config.SchemaConfig) Client

type KeyEncoder

type KeyEncoder func(schema config.SchemaConfig, chk chunk.Chunk) string

KeyEncoder is used to encode chunk keys before writing/retrieving chunks from the underlying ObjectClient Schema/Chunk are passed as arguments to allow this to improve over revisions

type MetricsChunkClient

type MetricsChunkClient struct {
	Client Client
	// contains filtered or unexported fields
}

takes a chunk client and exposes metrics for its operations.

func NewMetricsChunkClient

func NewMetricsChunkClient(client Client, metrics ChunkClientMetrics) MetricsChunkClient

func (MetricsChunkClient) DeleteChunk

func (c MetricsChunkClient) DeleteChunk(ctx context.Context, userID, chunkID string) error

func (MetricsChunkClient) GetChunks

func (c MetricsChunkClient) GetChunks(ctx context.Context, chunks []chunk.Chunk) ([]chunk.Chunk, error)

func (MetricsChunkClient) IsChunkNotFoundErr

func (c MetricsChunkClient) IsChunkNotFoundErr(err error) bool

func (MetricsChunkClient) PutChunks

func (c MetricsChunkClient) PutChunks(ctx context.Context, chunks []chunk.Chunk) error

func (MetricsChunkClient) Stop

func (c MetricsChunkClient) Stop()

type ObjectAndIndexClient

type ObjectAndIndexClient interface {
	PutChunksAndIndex(ctx context.Context, chunks []chunk.Chunk, index index.WriteBatch) error
}

ObjectAndIndexClient allows optimisations where the same client handles both

type ObjectClient

type ObjectClient interface {
	PutObject(ctx context.Context, objectKey string, object io.ReadSeeker) error
	// NOTE: The consumer of GetObject should always call the Close method when it is done reading which otherwise could cause a resource leak.
	GetObject(ctx context.Context, objectKey string) (io.ReadCloser, int64, error)

	// List objects with given prefix.
	//
	// If delimiter is empty, all objects are returned, even if they are in nested in "subdirectories".
	// If delimiter is not empty, it is used to compute common prefixes ("subdirectories"),
	// and objects containing delimiter in the name will not be returned in the result.
	//
	// For example, if the prefix is "notes/" and the delimiter is a slash (/) as in "notes/summer/july", the common prefix is "notes/summer/".
	// Common prefixes will always end with passed delimiter.
	//
	// Keys of returned storage objects have given prefix.
	List(ctx context.Context, prefix string, delimiter string) ([]StorageObject, []StorageCommonPrefix, error)
	DeleteObject(ctx context.Context, objectKey string) error
	IsObjectNotFoundErr(err error) bool
	Stop()
}

ObjectClient is used to store arbitrary data in Object Store (S3/GCS/Azure/...)

type StorageCommonPrefix

type StorageCommonPrefix string

StorageCommonPrefix represents a common prefix aka a synthetic directory in Object Store. It is guaranteed to always end with delimiter passed to List method.

type StorageObject

type StorageObject struct {
	Key        string
	ModifiedAt time.Time
}

StorageObject represents an object being stored in an Object Store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL