store

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package store defines the aggregate persistence interface for Trove metadata. Backends: PostgreSQL, SQLite, MongoDB, and Memory.

Index

Constants

This section is empty.

Variables

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

ErrNotFound is returned when a requested entity does not exist.

Functions

This section is empty.

Types

type ListConfig

type ListConfig struct {
	Prefix    string
	Limit     int
	Offset    int
	TenantKey string
}

ListConfig holds list query parameters.

func ApplyListOptions

func ApplyListOptions(opts []ListOption) ListConfig

ApplyListOptions applies list options to a default config.

type ListOption

type ListOption func(*ListConfig)

ListOption configures a list query.

func WithLimit

func WithLimit(n int) ListOption

WithLimit sets the maximum number of results.

func WithOffset

func WithOffset(n int) ListOption

WithOffset sets the pagination offset.

func WithPrefix

func WithPrefix(prefix string) ListOption

WithPrefix filters objects by key prefix.

func WithTenantKey

func WithTenantKey(key string) ListOption

WithTenantKey filters by tenant.

type Store

type Store interface {
	// DB returns the underlying Grove DB (nil for memory store).
	DB() *grove.DB

	// Ping checks database connectivity.
	Ping(ctx context.Context) error

	// Close closes the store connection.
	Close() error

	// Migrate runs all schema migrations.
	Migrate(ctx context.Context, extraGroups ...*migrate.Group) error

	CreateBucket(ctx context.Context, b *model.Bucket) error
	GetBucket(ctx context.Context, id string) (*model.Bucket, error)
	GetBucketByName(ctx context.Context, name string) (*model.Bucket, error)
	ListBuckets(ctx context.Context, tenantKey string) ([]*model.Bucket, error)
	UpdateBucket(ctx context.Context, b *model.Bucket) error
	DeleteBucket(ctx context.Context, id string) error

	CreateObject(ctx context.Context, o *model.Object) error
	GetObject(ctx context.Context, id string) (*model.Object, error)
	GetObjectByKey(ctx context.Context, bucketID, key string) (*model.Object, error)
	ListObjects(ctx context.Context, bucketID string, opts ...ListOption) ([]*model.Object, error)
	ListAllObjects(ctx context.Context, limit int) ([]*model.Object, error)
	UpdateObject(ctx context.Context, o *model.Object) error
	SoftDeleteObject(ctx context.Context, id string) error

	CreateUploadSession(ctx context.Context, u *model.UploadSession) error
	GetUploadSession(ctx context.Context, id string) (*model.UploadSession, error)
	UpdateUploadSession(ctx context.Context, u *model.UploadSession) error
	ListUploads(ctx context.Context) ([]*model.UploadSession, error)
	ListExpiredUploads(ctx context.Context) ([]*model.UploadSession, error)

	PutCASEntry(ctx context.Context, entry *model.CASEntry) error
	GetCASEntry(ctx context.Context, hash string) (*model.CASEntry, error)
	ListCASEntries(ctx context.Context) ([]*model.CASEntry, error)
	ListUnpinnedCAS(ctx context.Context) ([]*model.CASEntry, error)
	IncrementCASRef(ctx context.Context, hash string) error
	DecrementCASRef(ctx context.Context, hash string) error
	SetCASPinned(ctx context.Context, hash string, pinned bool) error
	DeleteCASEntry(ctx context.Context, hash string) error

	ListQuotas(ctx context.Context) ([]*model.Quota, error)
	GetQuota(ctx context.Context, tenantKey string) (*model.Quota, error)
	UpdateQuotaUsage(ctx context.Context, tenantKey string, deltaBytes, deltaObjects int64) error
	SetQuota(ctx context.Context, q *model.Quota) error
	DeleteQuota(ctx context.Context, tenantKey string) error
}

Store is the aggregate persistence interface for Trove metadata. A single backend (postgres, sqlite, mongo, memory) implements all methods.

Directories

Path Synopsis
Package memory provides an in-memory implementation of store.Store for testing.
Package memory provides an in-memory implementation of store.Store for testing.
Package mongo implements the Trove store interface using MongoDB via Grove ORM.
Package mongo implements the Trove store interface using MongoDB via Grove ORM.
Package postgres implements the Trove store interface using grove ORM (PostgreSQL).
Package postgres implements the Trove store interface using grove ORM (PostgreSQL).
Package sqlite implements the Trove store interface using grove ORM (SQLite).
Package sqlite implements the Trove store interface using grove ORM (SQLite).

Jump to

Keyboard shortcuts

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