Help us shape the future of Go! Take the 2026 Go Developer Survey

trove

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package trove adapts a *trove.Trove instance as an artifact.Backend.

It is the reference backend for Dispatch's artifact plane, but not a required one: the core depends only on the artifact.Backend interface, so any object store can be plugged in instead.

Two Trove features carry through without any code here. Its write-path middleware means compression, AES-256-GCM encryption, and virus scanning are configuration rather than Dispatch concerns — and scanning on write is what lets a malicious upload be rejected before any memory-unsafe parser opens it. Its multi-store routing means the backend name recorded on each artifact is simply the Trove store it lives in.

Index

Constants

View Source
const DefaultName = "trove"

DefaultName is the backend identifier used when none is configured.

Variables

View Source
var ErrRangeUnsupported = errors.New("trove: driver does not support range reads")

ErrRangeUnsupported means the underlying Trove driver cannot serve byte ranges, so the caller must read the whole object instead.

Functions

This section is empty.

Types

type Backend

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

Backend adapts a *trove.Trove as an artifact.Backend.

func New

func New(t *trovelib.Trove, opts ...Option) *Backend

New wraps a Trove instance as an artifact.Backend.

func (*Backend) Create

func (b *Backend) Create(ctx context.Context, bucket, key string) (artifact.Writer, error)

Create begins writing a new object.

Trove's Put consumes a reader, so the writer drives it from a pipe on a background goroutine and joins that goroutine in Commit or Abort.

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, ref artifact.Ref) error

Delete removes the object. Deleting a missing object is not an error, which makes the purge pass idempotent under retry.

func (*Backend) Name

func (b *Backend) Name() string

Name identifies this backend.

func (*Backend) Open

func (b *Backend) Open(ctx context.Context, ref artifact.Ref) (io.ReadCloser, error)

Open returns a reader over the object's bytes.

func (*Backend) OpenRange

func (b *Backend) OpenRange(ctx context.Context, ref artifact.Ref, off, n int64) (io.ReadCloser, error)

OpenRange returns a reader over n bytes starting at off. A negative n reads to the end.

Range support is a Trove driver capability, not a Get option: a driver that lacks it silently returns the entire object. Rather than hand back more bytes than asked for, this reports ErrRangeUnsupported so callers can fall back deliberately.

func (*Backend) PresignGet

func (b *Backend) PresignGet(ctx context.Context, ref artifact.Ref, ttl time.Duration) (string, error)

PresignGet returns a time-limited read URL when the underlying driver supports pre-signing, and ErrNotFound-free failure otherwise.

func (*Backend) Stat

func (b *Backend) Stat(ctx context.Context, ref artifact.Ref) (artifact.ObjectInfo, error)

Stat reports the object's size and content type.

func (*Backend) SupportsPresign

func (b *Backend) SupportsPresign(ref artifact.Ref) bool

SupportsPresign reports the signing capability of the artifact's routed driver.

type Option

type Option func(*Backend)

Option configures the Backend.

func WithName

func WithName(name string) Option

WithName overrides the backend identifier recorded on each artifact. Use the Trove store's name when running multi-store so an artifact's backend field points at the store that actually holds it.

Jump to

Keyboard shortcuts

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