objectstore

package
v0.1.102 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package objectstore provides the small S3-compatible object-store surface used by Shrike. It intentionally owns HTTP and signing rather than exposing an SDK client to API packages.

Index

Constants

View Source
const (
	BackblazeRegion = "eu-central-003"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FilePruneOptions added in v0.1.80

type FilePruneOptions struct {
	HighWatermarkPercent int
	LowWatermarkPercent  int
	MinimumAge           time.Duration
	DryRun               bool
	Now                  time.Time
}

FilePruneOptions controls the high/low-watermark image eviction pass. Access recency comes from filesystem atime; production mounts must not use noatime. Relatime is sufficient and deliberately coarsens write traffic.

type FilePruneResult added in v0.1.80

type FilePruneResult struct {
	Triggered        bool   `json:"triggered"`
	DryRun           bool   `json:"dry_run"`
	ObjectsScanned   uint64 `json:"objects_scanned"`
	ObjectsDeleted   uint64 `json:"objects_deleted"`
	BytesReclaimed   uint64 `json:"bytes_reclaimed"`
	InodesReclaimed  uint64 `json:"inodes_reclaimed"`
	BytesUsedBefore  uint64 `json:"bytes_used_before"`
	BytesUsedAfter   uint64 `json:"bytes_used_after"`
	InodesUsedBefore uint64 `json:"inodes_used_before"`
	InodesUsedAfter  uint64 `json:"inodes_used_after"`
}

type FileStore added in v0.1.5

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

FileStore implements the image object-store contract on a local filesystem. Bodies and metadata are replaced atomically, so concurrent readers never see a partially written image.

func NewFileStore added in v0.1.5

func NewFileStore(root string, maximum int64) (*FileStore, error)

func (*FileStore) Delete added in v0.1.5

func (s *FileStore) Delete(_ context.Context, key string) error

func (*FileStore) GetObject added in v0.1.5

func (s *FileStore) GetObject(_ context.Context, key string) (*Object, error)

func (*FileStore) Prune added in v0.1.80

func (s *FileStore) Prune(ctx context.Context, options FilePruneOptions) (FilePruneResult, error)

Prune evicts least-recently-accessed objects when either byte or inode use reaches the high watermark, and continues until both are below the low watermark. Metadata sidecars are always removed with their object.

func (*FileStore) PutWithOptions added in v0.1.5

func (s *FileStore) PutWithOptions(_ context.Context, key string, body []byte, options PutOptions) error

func (*FileStore) Stat added in v0.1.5

func (s *FileStore) Stat(_ context.Context, key string) (*ObjectInfo, error)

type Object

type Object struct {
	Body []byte
	ObjectInfo
}

Object is an object body together with the metadata returned by B2.

type ObjectInfo

type ObjectInfo struct {
	Key          string
	Size         int64
	ETag         string
	ContentType  string
	CacheControl string
	LastModified time.Time
	Metadata     map[string]string
}

ObjectInfo is the metadata available from S3 HEAD and GET responses.

type PutOptions

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

type S3Options

type S3Options struct {
	Endpoint          string
	Bucket            string
	Region            string
	AccessKeyID       string
	SecretAccessKey   string
	HTTPClient        *http.Client
	CacheTTL          time.Duration
	CacheMaximumBytes int64
	DisableCache      bool
	MaximumBytes      int64
	// contains filtered or unexported fields
}

type S3Store

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

S3Store is a path-style, Signature V4 S3 client with a small in-process read cache. Backblaze B2 implements this protocol and uses path-style bucket URLs at the endpoint already present in the TypeScript deployment.

func NewS3Store

func NewS3Store(options S3Options) (*S3Store, error)

func (*S3Store) Delete

func (s *S3Store) Delete(ctx context.Context, key string) error

func (*S3Store) Get

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

func (*S3Store) GetObject

func (s *S3Store) GetObject(ctx context.Context, key string) (*Object, error)

GetObject bypasses the small generic cache so callers that need current ETags and metadata do not accidentally pair a cached body with fresh object metadata. The image service owns its own response cache and uses this method.

func (*S3Store) Put

func (s *S3Store) Put(
	ctx context.Context,
	key string,
	body []byte,
	contentType string,
) error

func (*S3Store) PutWithOptions

func (s *S3Store) PutWithOptions(
	ctx context.Context,
	key string,
	body []byte,
	options PutOptions,
) error

func (*S3Store) Stat

func (s *S3Store) Stat(ctx context.Context, key string) (*ObjectInfo, error)

Stat returns nil for a missing object.

Jump to

Keyboard shortcuts

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