objstore

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package objstore is the object store seam of the store service. One Store or Bucket is one bucket. Implementations: Google Cloud Storage (internal/objstore/gcs), a filesystem directory (internal/objstore/fs) and Memory, a Store only.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("objstore: object not found")

Functions

This section is empty.

Types

type Attrs

type Attrs struct {
	Size        int64
	ContentType string
	Metadata    map[string]string
	MD5         []byte
	Generation  int64
}

Attrs describes one stored object; MD5 holds raw bytes.

type Bucket

type Bucket interface {
	Store
	// Attrs answers ErrNotFound for a missing object.
	Attrs(ctx context.Context, key string) (Attrs, error)
	// Open reads one generation of key (0: the live one); ErrNotFound if
	// missing. Its Attrs hold Size, ContentType and Generation only.
	Open(ctx context.Context, key string, generation int64) (io.ReadCloser, Attrs, error)
	List(ctx context.Context, prefix string) ([]string, error)
	// Delete removes the live object. A missing object is not an error.
	Delete(ctx context.Context, key string) error
	// Copy copies one generation of Source (0: the live one) and returns the
	// generation it wrote; ErrNotFound for a missing source.
	Copy(ctx context.Context, c Copy) (int64, error)
}

Bucket is the whole object API of one bucket.

type Buckets

type Buckets interface {
	Bucket(name string) Bucket
}

Buckets opens a bucket by name.

type Copy

type Copy struct {
	Source      string
	Generation  int64
	Destination string
	Metadata    map[string]string
	CreateOnly  bool
}

Copy copies one object generation; Metadata replaces that of the source.

type Memory

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

Memory is an in-memory Store.

func NewMemory

func NewMemory() *Memory

func (*Memory) Create

func (m *Memory) Create(_ context.Context, key string, data []byte) (bool, error)

func (*Memory) Get

func (m *Memory) Get(_ context.Context, key string) ([]byte, error)

func (*Memory) GetRange

func (m *Memory) GetRange(ctx context.Context, key string, off, n int64) ([]byte, error)

func (*Memory) Keys

func (m *Memory) Keys() []string

Keys lists the stored keys.

type Store

type Store interface {
	// Create writes data when key is absent and reports whether it wrote. A
	// stored object is never replaced.
	Create(ctx context.Context, key string, data []byte) (created bool, err error)
	Get(ctx context.Context, key string) ([]byte, error)
	// GetRange returns up to n bytes from off, fewer at the end of the object.
	GetRange(ctx context.Context, key string, off, n int64) ([]byte, error)
}

Directories

Path Synopsis
Package fs backs the objstore seam with a directory.
Package fs backs the objstore seam with a directory.
Package gcs backs the objstore seam with Google Cloud Storage.
Package gcs backs the objstore seam with Google Cloud Storage.

Jump to

Keyboard shortcuts

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