archive

package
v0.33.9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package archive uploads task HTML to cold object storage (R2, S3, B2) and exposes the canonical key layout used by the live HTML persister.

The legacy hot-to-cold sweep (Supabase Storage → R2) was removed once R2 became the hot store. Only the cold-storage provider plumbing and the path constructors remain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColdKey

func ColdKey(jobID, taskID string) string

ColdKey returns the canonical cold-storage object key for a task HTML blob.

func TaskHTMLObjectPath

func TaskHTMLObjectPath(jobID, taskID string) string

TaskHTMLObjectPath returns the canonical object path for a task HTML blob.

When ARCHIVE_PATH_PREFIX is set, it is prepended (with a single "/" join) so review-app deployments can land in their own R2 sub-tree without touching the production bucket layout — e.g. ARCHIVE_PATH_PREFIX=347 on a review app produces "347/jobs/<job>/tasks/<task>/page-content.html.gz". Empty prefix preserves the original production path exactly.

Types

type ColdStorageProvider

type ColdStorageProvider interface {
	// Ping verifies that the provider can reach the given bucket.
	// Call once at startup to catch bad credentials/endpoints early.
	Ping(ctx context.Context, bucket string) error
	// Upload writes data to the given bucket/key.
	Upload(ctx context.Context, bucket, key string, data io.Reader, opts UploadOptions) error
	// Download retrieves an object by bucket/key.
	Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
	// Exists returns true if the object exists and is readable.
	Exists(ctx context.Context, bucket, key string) (bool, error)
	// Provider returns the short name of the backend ("r2", "s3", "b2").
	Provider() string
}

ColdStorageProvider abstracts an S3-compatible object store.

func ProviderFromEnv

func ProviderFromEnv() (ColdStorageProvider, error)

ProviderFromEnv builds a ColdStorageProvider from ARCHIVE_* env vars. Returns (nil, nil) if ARCHIVE_PROVIDER is unset.

type Config

type Config struct {
	Provider string // "r2", "s3", "b2"
	Bucket   string // cold-storage bucket name
}

Config controls the cold-storage provider used by the HTML persister.

func ConfigFromEnv

func ConfigFromEnv() *Config

ConfigFromEnv builds a Config from ARCHIVE_* environment variables. Returns nil if ARCHIVE_PROVIDER or ARCHIVE_BUCKET is unset (feature disabled).

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults, overridable via environment.

type S3Provider

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

S3Provider implements ColdStorageProvider for any S3-compatible service (Cloudflare R2, Backblaze B2, AWS S3, MinIO, etc.).

func NewS3Provider

func NewS3Provider(endpoint, accessKeyID, secretAccessKey, region, providerName string) (*S3Provider, error)

NewS3Provider creates a provider from explicit credentials.

func (*S3Provider) Delete

func (p *S3Provider) Delete(ctx context.Context, bucket, key string) error

func (*S3Provider) Download

func (p *S3Provider) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)

func (*S3Provider) Exists

func (p *S3Provider) Exists(ctx context.Context, bucket, key string) (bool, error)

func (*S3Provider) Ping

func (p *S3Provider) Ping(ctx context.Context, bucket string) error

func (*S3Provider) Provider

func (p *S3Provider) Provider() string

func (*S3Provider) Upload

func (p *S3Provider) Upload(ctx context.Context, bucket, key string, data io.Reader, opts UploadOptions) error

type UploadOptions

type UploadOptions struct {
	ContentType     string
	ContentEncoding string
	Metadata        map[string]string
}

UploadOptions controls metadata attached to a cold-storage object.

Jump to

Keyboard shortcuts

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