github.com/sequix/cortex@v1.1.6/pkg/chunk/storage_client.go (about)

     1  package chunk
     2  
     3  import "context"
     4  
     5  // IndexClient is a client for the storage of the index (e.g. DynamoDB or Bigtable).
     6  type IndexClient interface {
     7  	Stop()
     8  
     9  	// For the write path.
    10  	NewWriteBatch() WriteBatch
    11  	BatchWrite(context.Context, WriteBatch) error
    12  
    13  	// For the read path.
    14  	QueryPages(ctx context.Context, queries []IndexQuery, callback func(IndexQuery, ReadBatch) (shouldContinue bool)) error
    15  }
    16  
    17  // ObjectClient is for storing and retrieving chunks.
    18  type ObjectClient interface {
    19  	Stop()
    20  
    21  	PutChunks(ctx context.Context, chunks []Chunk) error
    22  	GetChunks(ctx context.Context, chunks []Chunk) ([]Chunk, error)
    23  }
    24  
    25  // ObjectAndIndexClient allows optimisations where the same client handles both
    26  type ObjectAndIndexClient interface {
    27  	PutChunkAndIndex(ctx context.Context, c Chunk, index WriteBatch) error
    28  }
    29  
    30  // WriteBatch represents a batch of writes.
    31  type WriteBatch interface {
    32  	Add(tableName, hashValue string, rangeValue []byte, value []byte)
    33  }
    34  
    35  // ReadBatch represents the results of a QueryPages.
    36  type ReadBatch interface {
    37  	Iterator() ReadBatchIterator
    38  }
    39  
    40  // ReadBatchIterator is an iterator over a ReadBatch.
    41  type ReadBatchIterator interface {
    42  	Next() bool
    43  	RangeValue() []byte
    44  	Value() []byte
    45  }