objectstore

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package objectstore provides an S3-compatible object store for generated assets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetKey

func AssetKey(orgID, projectID, assetID, ext string) string

AssetKey builds an org/project-scoped object key.

Types

type Config

type Config struct {
	Endpoint  string // host:port (no scheme), e.g. localhost:9000
	AccessKey string
	SecretKey string
	Region    string
	Bucket    string
	UseSSL    bool
	PathStyle bool
}

Config configures an S3-compatible endpoint.

type FanoutStore added in v0.3.0

type FanoutStore struct {
	Primary snapshot.Store
	Mirror  *SnapshotStore
}

FanoutStore writes to a primary store then mirrors to an object-store snapshot store.

func (*FanoutStore) Latest added in v0.3.0

func (f *FanoutStore) Latest(ctx context.Context) (*snapshot.Snapshot, error)

func (*FanoutStore) Put added in v0.3.0

func (f *FanoutStore) Put(ctx context.Context, snap *snapshot.Snapshot) (int64, error)

func (*FanoutStore) Watch added in v0.3.0

func (f *FanoutStore) Watch(ctx context.Context, pollInterval time.Duration, onUpdate func(*snapshot.Snapshot)) error

type PutOptions

type PutOptions struct {
	ContentType string
	Metadata    map[string]string
}

PutOptions controls object metadata on write.

type S3

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

S3 is a MinIO/S3-backed Store.

func New

func New(cfg Config) (*S3, error)

New builds an S3 store. Returns nil, nil when Endpoint or Bucket is empty.

func (*S3) Get added in v0.3.0

func (s *S3) Get(ctx context.Context, key string) ([]byte, error)

Get downloads an object into memory.

func (*S3) PresignGet

func (s *S3) PresignGet(ctx context.Context, key string, ttl time.Duration) (string, error)

PresignGet returns a time-limited GET URL.

func (*S3) Put

func (s *S3) Put(ctx context.Context, key string, body io.Reader, size int64, opts PutOptions) error

Put uploads an object.

type SnapshotStore added in v0.3.0

type SnapshotStore struct {
	Blob   Store
	Prefix string
}

SnapshotStore implements snapshot.Store using an S3-compatible object store. Layout: {prefix}/{version}.json and {prefix}/latest (plain version number).

func NewSnapshotStore added in v0.3.0

func NewSnapshotStore(blob Store, prefix string) *SnapshotStore

func (*SnapshotStore) ForRegion added in v0.3.0

func (s *SnapshotStore) ForRegion(regionSlug string) *SnapshotStore

ForRegion returns a store rooted at {prefix}/{regionSlug}.

func (*SnapshotStore) Latest added in v0.3.0

func (s *SnapshotStore) Latest(ctx context.Context) (*snapshot.Snapshot, error)

Latest loads the snapshot pointed at by the latest pointer.

func (*SnapshotStore) Put added in v0.3.0

func (s *SnapshotStore) Put(ctx context.Context, snap *snapshot.Snapshot) (int64, error)

Put writes the snapshot blob and updates the latest pointer.

func (*SnapshotStore) Watch added in v0.3.0

func (s *SnapshotStore) Watch(ctx context.Context, pollInterval time.Duration, onUpdate func(*snapshot.Snapshot)) error

Watch polls for newer snapshots (no push notifications).

type Store

type Store interface {
	Put(ctx context.Context, key string, body io.Reader, size int64, opts PutOptions) error
	Get(ctx context.Context, key string) ([]byte, error)
	PresignGet(ctx context.Context, key string, ttl time.Duration) (string, error)
}

Store is the asset / blob persistence port.

Jump to

Keyboard shortcuts

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