blob

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package blob is the storage-layer port (ADR-0007): opaque byte objects behind the blob.Bucket port. It is the bytes substrate, sibling to the store (records) — deliberately named "blob", not "storage", to stay distinct from "store".

This package imports no driver library; the gocloud.dev/blob adapter (memory / file / S3, all pure-Go) lives in internal/blob/gocloud.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	Key     string
	Size    int64
	ModTime time.Time
	// MD5 is the MD5 of the content; empty when the driver has no digest for the object (ADR-0159).
	MD5         []byte
	ContentType string
	Metadata    map[string]string // user metadata, lowercase keys
}

Attributes describes one object. List fills Key, Size, ModTime and MD5; Bucket.Attributes fills all.

func Stat added in v0.2.1

func Stat(ctx context.Context, b Bucket, key string) (Attributes, bool, error)

Stat returns the attributes of the object at key through Bucket.Attributes, which reads metadata, never the object (ADR-0159). found=false ⇒ no object at key, or a key the driver cannot hold as an object.

type Bucket

type Bucket interface {
	Get(ctx context.Context, key string) ([]byte, error)
	Put(ctx context.Context, key string, data []byte, opts PutOptions) error
	Delete(ctx context.Context, key string) error
	Exists(ctx context.Context, key string) (bool, error)
	List(ctx context.Context, prefix string) ([]Attributes, error)
	// ListAfter returns at most limit objects under prefix whose key sorts strictly after `after`, sorted by key,
	// with the fields List fills; more is true exactly when a further key under prefix exists. limit < 1 is
	// fault.Invalid (ADR-0184).
	ListAfter(ctx context.Context, prefix, after string, limit int) (items []Attributes, more bool, err error)
	// Attributes reads one object's attributes without its content; fault.NotFound if absent.
	Attributes(ctx context.Context, key string) (Attributes, error)
	SignedURL(ctx context.Context, key string, opts SignOptions) (string, error)
	Close() error
}

Bucket is the storage-layer port: opaque byte objects keyed by a path string. Errors are api/fault kinds; every method is ctx-first.

func Capped added in v0.2.1

func Capped(inner Bucket, maxBytes int64) Bucket

Capped returns a view of inner whose Put refuses an object larger than maxBytes with fault.PayloadTooLarge: the Bucket.spec.maxObjectBytes per-object policy (ADR-0080, ADR-0148). It also refuses to sign a PUT URL with fault.Forbidden, since the upload then bypasses Put and SignOptions carries no size limit to bind it. maxBytes <= 0 returns inner unchanged. It forwards the optional RangeReader capability when inner implements it.

func Prefixed

func Prefixed(inner Bucket, keyPrefix string) Bucket

Prefixed returns a Bucket view of inner whose keys are all transparently prefixed with keyPrefix (ADR-0080): it scopes a single shared substrate bucket into many logical buckets (e.g. one per (namespace, Bucket) S3 domain) without a separate backend per bucket. A trailing "/" on keyPrefix is recommended for a clean boundary. It forwards the optional RangeReader capability when inner implements it.

type PutOptions added in v0.4.0

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

PutOptions configures a Put. The zero value stores no metadata and lets the driver pick the content type.

type RangeReader

type RangeReader interface {
	// GetRange returns bytes [offset, offset+length) of the object at key.
	// A negative length means "to end". offset must be >= 0. fault.NotFound if the
	// key is absent; fault.Invalid for a negative offset.
	GetRange(ctx context.Context, key string, offset, length int64) ([]byte, error)
}

RangeReader is an OPTIONAL capability a blob.Bucket driver MAY implement: a byte-range read of an object (ADR-0080). The s3gateway type-asserts a Bucket to RangeReader to serve DuckDB's ranged Parquet reads efficiently and FALLS BACK to a full Get+slice when the driver does not implement it. Keeping it a separate, optional interface keeps the blob.Bucket port minimal and the contract tests additive.

type SignMethod

type SignMethod string

SignMethod is the typed HTTP method a SignedURL grants (ADR-0002: typed over magic strings).

const (
	SignGet    SignMethod = "GET"
	SignPut    SignMethod = "PUT"
	SignDelete SignMethod = "DELETE"
)

type SignOptions

type SignOptions struct {
	Method SignMethod
	Expiry time.Duration
}

SignOptions configures a SignedURL request. A zero Method means SignGet; a zero Expiry means the driver's default (15m).

Directories

Path Synopsis
Package blobcontract is the shared conformance suite for the blob.Bucket port (ADR-0007).
Package blobcontract is the shared conformance suite for the blob.Bucket port (ADR-0007).
Package gocloud is the gocloud.dev/blob driver for the blob.Bucket port (ADR-0007): memory / file / S3 by URL, all pure-Go (no cgo).
Package gocloud is the gocloud.dev/blob driver for the blob.Bucket port (ADR-0007): memory / file / S3 by URL, all pure-Go (no cgo).
Package s3gateway is the funcd S3-protocol frontend over the blob.Bucket substrate (ADR-0080), with in-platform identity via funcd-managed per-principal SigV4 keypairs resolved by an in-process versitygw auth.IAMService (ADR-0085).
Package s3gateway is the funcd S3-protocol frontend over the blob.Bucket substrate (ADR-0080), with in-platform identity via funcd-managed per-principal SigV4 keypairs resolved by an in-process versitygw auth.IAMService (ADR-0085).

Jump to

Keyboard shortcuts

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