Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package store puts and gets original document bytes in object storage.

Index

Constants

This section is empty.

Variables

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

ErrNotFound is returned by Get and Delete when no object exists at a URI. Delete implementations treat it as success — deleting an object that is already gone is the outcome the caller asked for — but it is exported so callers distinguishing "never stored" from "storage broke" can.

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore is an in-memory Store, for tests. Not safe to use as a production backend — nothing is persisted.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore builds an empty MemoryStore.

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(_ context.Context, uri string) error

Delete removes the object, if present. Missing is not an error.

func (*MemoryStore) Get

func (s *MemoryStore) Get(_ context.Context, uri string) (io.ReadCloser, error)

func (*MemoryStore) Len

func (s *MemoryStore) Len() int

Len reports how many objects are held, for tests asserting that a delete actually purged the bytes rather than only the database row.

func (*MemoryStore) Put

func (s *MemoryStore) Put(_ context.Context, tenantID uuid.UUID, filename string, data []byte, _ string) (string, error)

type MinIOConfig

type MinIOConfig struct {
	Endpoint  string
	AccessKey string
	SecretKey string
	Bucket    string
	UseSSL    bool
}

MinIOConfig configures MinIOStore. Works against MinIO itself or any S3-compatible endpoint (AWS S3, R2, B2, ...).

type MinIOStore

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

MinIOStore is an S3-compatible Store implementation.

func NewMinIOStore

func NewMinIOStore(ctx context.Context, cfg MinIOConfig) (*MinIOStore, error)

NewMinIOStore builds a MinIOStore and ensures its bucket exists.

func (*MinIOStore) Delete

func (s *MinIOStore) Delete(ctx context.Context, uri string) error

Delete removes the object at uri. S3 DELETE is already idempotent — it reports success for a key that does not exist — so this needs no special-casing to satisfy the interface's idempotency contract.

func (*MinIOStore) Get

func (s *MinIOStore) Get(ctx context.Context, uri string) (io.ReadCloser, error)

Get retrieves the object at uri (as returned by Put).

func (*MinIOStore) Put

func (s *MinIOStore) Put(ctx context.Context, tenantID uuid.UUID, filename string, data []byte, mimeType string) (string, error)

Put uploads data under a tenant-prefixed, collision-resistant key and returns an s3:// URI identifying it.

type Store

type Store interface {
	// Put uploads data under a tenant-prefixed key and returns the URI it
	// was stored at.
	Put(ctx context.Context, tenantID uuid.UUID, filename string, data []byte, mimeType string) (uri string, err error)
	// Get retrieves the object at uri. The caller must close the reader.
	Get(ctx context.Context, uri string) (io.ReadCloser, error)
	// Delete removes the object at uri. It is idempotent: deleting a URI
	// that holds no object returns nil, so a retried cleanup does not fail
	// on its second pass.
	Delete(ctx context.Context, uri string) error
}

Store puts and gets raw document bytes, keyed by a tenant-scoped URI.

Jump to

Keyboard shortcuts

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