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

objectstore

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package objectstore is the studio/CLI seam to a versioned object store (spec 0039): workspace MEDIA lives in a bucket, git keeps the authored state plus a media.lock manifest pinning each file's content hash and object version. The backend is pluggable behind the narrow Store interface and chosen from the TOP-LEVEL `storage:` config section (0039 D5 — deliberately not providers.*, storage is not a generation backend). An unset provider is a supported state: callers degrade to local-only behaviour (R-STO-5).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConfigured: no storage.provider set — local-only mode, not a fault.
	ErrNotConfigured = errors.NewSentinel("keyrx.not_configured", "no object store configured (storage.provider unset)")
	// ErrUnknownProvider: storage.provider names an unregistered adapter.
	ErrUnknownProvider = errors.NewSentinel("keyrx.unknown_provider", "unknown storage provider")
	// ErrNotFound: the key (or the requested version of it) does not exist.
	ErrNotFound = errors.NewSentinel("keyrx.not_found", "object not found")
)

Sentinel states callers branch on.

View Source
var Default = NewRegistry()

Default is the process-wide registry adapters register into from init().

Functions

func Key

func Key(prefix, slug, relpath string) string

Key composes the bucket key for a workspace file (0039 §3.3): <prefix>/reels/<slug>/<relpath>, slash-separated; a blank prefix drops its segment. relpath must already be slash-separated (workspace-relative).

Types

type Config

type Config struct {
	Reader config.Reader
}

Config is what a constructor receives: the active config reader, from which the adapter reads its own storage.<name>.* block (bucket, region, prefix, endpoint — never credentials, which resolve via the provider's own chain; R-STO-4).

type Constructor

type Constructor func(Config) (Store, error)

Constructor builds a Store from the active config.

type Info

type Info struct {
	Size      int64
	ETag      string
	VersionID string
	// SHA256 is the content hash recorded at Put time (object metadata), ""
	// when the object predates keryx or the backend can't echo it.
	SHA256 string
}

Info describes a stored object.

type PutResult

type PutResult struct {
	VersionID string
	ETag      string
}

PutResult identifies the object version a Put created.

type Registry

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

Registry resolves the configured storage adapter. Mirrors the provider factory pattern (0001 §3.4) but keys off top-level `storage.provider`.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry (tests); package users share Default.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns the registered adapter names, sorted.

func (*Registry) Register

func (r *Registry) Register(name string, c Constructor)

Register adds a named constructor. Adapters call this from an init() so that importing the adapter package wires it in.

func (*Registry) Resolve

func (r *Registry) Resolve(cfg config.Reader) (Store, error)

Resolve builds the configured Store. ErrNotConfigured when storage.provider is unset (callers treat that as local-only, not a fault); an unknown name is an error listing the registered adapters.

func (*Registry) Selected

func (r *Registry) Selected(cfg config.Reader) string

Selected returns the configured adapter name ("" = not configured).

type Store

type Store interface {
	// Put uploads r (size bytes, content sha256Hex) to key, returning the new
	// object version.
	Put(ctx context.Context, key string, r io.Reader, size int64, sha256Hex string) (PutResult, error)
	// Get streams the object at key; versionID "" means latest.
	Get(ctx context.Context, key, versionID string) (io.ReadCloser, error)
	// Head describes the object at key without fetching it; versionID "" means
	// latest.
	Head(ctx context.Context, key, versionID string) (Info, error)
	// Verify checks the backing store is reachable — the doctor check
	// (R-STO-10). It never creates or configures anything.
	Verify(ctx context.Context) error
	// List returns every key under prefix (used by `media gc` to find blobs no
	// manifest or ledger references).
	List(ctx context.Context, prefix string) ([]string, error)
	// Delete removes one object. keryx only ever calls this from the explicit,
	// opt-in `media gc` prune — never from push/pull (R-STO-6).
	Delete(ctx context.Context, key string) error
}

Store is the narrow object-store seam. Keys are full bucket keys (the caller composes them — see Key); implementations never interpret them. Puts overwrite in place — the bucket's own versioning is the history (R-STO-6: keryx never deletes objects or versions).

Directories

Path Synopsis
Package cdk is the multi-backend object-store adapter (spec 0040): one implementation over gocloud.dev/blob, which speaks S3, Google Cloud Storage, Azure Blob, the local filesystem and memory through a single portable API.
Package cdk is the multi-backend object-store adapter (spec 0040): one implementation over gocloud.dev/blob, which speaks S3, Google Cloud Storage, Azure Blob, the local filesystem and memory through a single portable API.
Package s3 is the S3 object-store adapter (spec 0039 §3.4): keryx's default storage backend, registered as storage.provider "s3".
Package s3 is the S3 object-store adapter (spec 0039 §3.4): keryx's default storage backend, registered as storage.provider "s3".

Jump to

Keyboard shortcuts

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