uploads

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationValues

func ApplicationValues(values store.Values) store.Values

ApplicationValues returns only application-owned upload document values. Storage metadata is always replaced by the manager after byte processing.

func IsBusy

func IsBusy(err error) bool

func IsStorageError

func IsStorageError(err error) bool

func ValidateNamespace

func ValidateNamespace(namespace string) error

ValidateNamespace rejects ambiguous or path-shaped storage ownership names.

Types

type BusyError

type BusyError struct{ Resource string }

BusyError means the bounded admission queue is full. Callers should retry after backoff instead of treating it as invalid content.

func (*BusyError) Error

func (err *BusyError) Error() string

type ImageInput

type ImageInput struct {
	ObjectKey  string
	FocalX     float64
	FocalY     float64
	CropX      float64
	CropY      float64
	CropWidth  float64
	CropHeight float64
}

ImageInput identifies an existing original image and the focal point used when regenerating configured cover variants.

type Input

type Input struct {
	Filename          string
	Reader            io.Reader
	Values            store.Values
	FileAdmissionHeld bool
}

type Manager

type Manager struct {
	Backend   storage.Backend
	Locker    store.UploadObjectLocker
	Namespace string
	Admission *WorkAdmission
}

func (Manager) AcquireFile

func (manager Manager) AcquireFile(ctx context.Context, bytes int64) (func(), error)

AcquireFile reserves compressed-byte capacity for a caller, such as remote download handling, that must allocate before Prepare receives its reader.

func (Manager) Duplicate

func (manager Manager) Duplicate(ctx context.Context, collection schema.Collection, source store.Values) (Prepared, error)

Duplicate copies every stored object owned by an upload document into a fresh object-key namespace. The returned values replace only storage-owned metadata; callers remain responsible for duplicating the document itself.

func (Manager) OwnsKey

func (manager Manager) OwnsKey(key string) bool

OwnsKey reports whether one object belongs to this exact application namespace. Collection ownership comes from the access-checked document reference rather than a mutable collection slug in the key.

func (Manager) Prepare

func (manager Manager) Prepare(ctx context.Context, collection schema.Collection, input Input) (Prepared, error)

func (Manager) RegenerateImage

func (manager Manager) RegenerateImage(ctx context.Context, collection schema.Collection, input ImageInput) (Prepared, error)

RegenerateImage creates a fresh set of configured variants from an existing original. The caller owns committing Values to the document and rolling back Keys if that commit fails.

func (Manager) Rollback

func (manager Manager) Rollback(ctx context.Context, prepared Prepared) error

type Prepared

type Prepared struct {
	Values store.Values
	Keys   []string
	// contains filtered or unexported fields
}

func (Prepared) Release

func (prepared Prepared) Release()

Release relinquishes the generated-object reservation after the owning document operation has committed. Rollback releases the same reservation after every staged object has been removed, so calling Release more than once is safe.

type StorageError

type StorageError struct{ Cause error }

func (*StorageError) Error

func (failure *StorageError) Error() string

func (*StorageError) Unwrap

func (failure *StorageError) Unwrap() error

type WorkAdmission

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

WorkAdmission bounds compressed upload bytes and decoded image work across every application hosted by one Ridu process.

func NewWorkAdmission

func NewWorkAdmission(fileBudgetBytes, imageBudgetBytes int64, queued int) *WorkAdmission

NewWorkAdmission constructs an isolated admission controller. It is public within the internal package so resource-bound behavior can be proven without consuming the process-wide production budget in tests.

func (*WorkAdmission) AcquireFile

func (admission *WorkAdmission) AcquireFile(ctx context.Context, bytes int64) (func(), error)

func (*WorkAdmission) AcquireImage

func (admission *WorkAdmission) AcquireImage(ctx context.Context, bytes int64) (func(), error)

Jump to

Keyboard shortcuts

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