storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package storage is the object-storage port for the document framework: the kernel never talks to S3/minio/GCS directly, it talks to an Adapter. Uploads and downloads go through short-lived presigned URLs so blob bytes never transit the API process. The memory adapter (NewMemory) backs tests and local dev; a production adapter (S3/minio) implements the same four methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	PresignPut(ctx context.Context, key string, ttl time.Duration) (PresignedURL, error)
	PresignGet(ctx context.Context, key string, ttl time.Duration) (PresignedURL, error)
	Stat(ctx context.Context, key string) (ObjectInfo, error)
	// Peek returns up to n leading bytes for MIME sniffing (http.DetectContentType
	// reads at most 512). Returns KindNotFound if the object is absent.
	Peek(ctx context.Context, key string, n int) ([]byte, error)
	Delete(ctx context.Context, key string) error
}

Adapter is the object-storage port.

A tenant-prefixed Key ("<tenant>/<document>/<version>") is minted by the document service; the adapter treats keys as opaque. PresignPut/PresignGet return URLs valid for ttl. Stat and Peek support confirm-time verification (size + SHA-256 + a MIME-sniff prefix); a real adapter implements Stat via a HEAD and Peek via a ranged GET. Delete backs retention voiding.

type Memory

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

Memory is an in-process Adapter for tests and local dev. Presigned URLs are synthetic ("mem://<key>?..."); the test/client uploads by calling Put with the bytes (standing in for the client's PUT to the presigned URL). Concurrency-safe.

func NewMemory

func NewMemory() *Memory

NewMemory returns an empty in-memory object store.

func (*Memory) Delete

func (m *Memory) Delete(_ context.Context, key string) error

func (*Memory) Has

func (m *Memory) Has(key string) bool

Has reports whether a key currently holds an object.

func (*Memory) Peek

func (m *Memory) Peek(_ context.Context, key string, n int) ([]byte, error)

func (*Memory) PresignGet

func (m *Memory) PresignGet(_ context.Context, key string, ttl time.Duration) (PresignedURL, error)

func (*Memory) PresignPut

func (m *Memory) PresignPut(_ context.Context, key string, ttl time.Duration) (PresignedURL, error)

func (*Memory) Put

func (m *Memory) Put(key string, data []byte)

Put simulates the client uploading bytes to a presigned PUT URL. Real adapters have no such method — the client PUTs directly to the object store.

func (*Memory) Stat

func (m *Memory) Stat(_ context.Context, key string) (ObjectInfo, error)

type ObjectInfo

type ObjectInfo struct {
	Size     int64
	Checksum string
}

ObjectInfo is what the store reports about a stored blob at confirm time. Checksum is the lowercase hex SHA-256 of the bytes.

type PresignedURL

type PresignedURL struct {
	URL       string
	Method    string
	ExpiresAt time.Time
}

PresignedURL is a time-boxed URL the client uses directly against the object store. Method is "PUT" (upload) or "GET" (download).

Jump to

Keyboard shortcuts

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