blob

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package blob defines the object store that holds PDFs and artifacts, and a registry of drivers selected by URL scheme. Drivers register themselves from init, as database/sql drivers do; import them for their side effect (for example blob/disk).

Stability

This package is for driver authors and the Inkless service itself. It may change incompatibly until v1.

Contract

A Store is safe for concurrent use. Objects are addressed by content: the key of an object is Key of the hex SHA-256 of its bytes, and drivers accept only keys of that form. Objects are written once and never replaced. Drivers do not check the digest; the caller verifies every Get against its key and fails closed on a mismatch.

Index

Constants

View Source
const DefaultURL = "file:blobs"

DefaultURL is used when no blob URL is configured: a directory named blobs in the working directory.

View Source
const MaxSize = 64 << 20

MaxSize is the largest object Get returns.

Variables

View Source
var (
	// ErrNotFound is returned by Get when the key does not exist.
	ErrNotFound = errors.New("blob: not found")
	// ErrTooLarge is returned by Get when an object exceeds MaxSize.
	ErrTooLarge = errors.New("blob: object too large")
	// ErrInvalidKey is returned for keys that are not content addresses.
	ErrInvalidKey = errors.New("blob: invalid key")
)

Functions

func Drivers

func Drivers() []string

Drivers returns the registered schemes.

func Key

func Key(sha256Hex string) string

Key returns the key of the object whose SHA-256 is sha256Hex.

func ReadAll

func ReadAll(r io.Reader) ([]byte, error)

ReadAll reads r to the end and returns ErrTooLarge if it holds more than MaxSize bytes.

func Register

func Register(scheme string, open Opener)

Register makes a driver available for URLs with the given scheme. It panics if the scheme is already registered.

func ValidKey

func ValidKey(key string) error

ValidKey returns ErrInvalidKey unless key has the form sha256/<64 lowercase hex digits>.

Types

type Opener

type Opener func(ctx context.Context, url string) (Store, error)

Opener opens a store from a URL whose scheme selected the driver.

type Store

type Store interface {
	// Put stores data under key. Putting an existing key succeeds without
	// changing it.
	Put(ctx context.Context, key string, data []byte) error
	// Get returns the object stored under key, or ErrNotFound.
	Get(ctx context.Context, key string) ([]byte, error)
}

Store holds immutable objects by content address.

func Open

func Open(ctx context.Context, url string) (Store, error)

Open opens the store for url (DefaultURL if empty) with the driver registered for its scheme.

Directories

Path Synopsis
Package blobtest is the conformance suite every blob driver must pass.
Package blobtest is the conformance suite every blob driver must pass.
Package disk registers the default blob driver for URLs of the form file:PATH (file:blobs, file:/var/lib/inkless/blobs).
Package disk registers the default blob driver for URLs of the form file:PATH (file:blobs, file:/var/lib/inkless/blobs).
Package s3 registers a blob driver for S3-compatible stores, selected by URLs of the form
Package s3 registers a blob driver for S3-compatible stores, selected by URLs of the form

Jump to

Keyboard shortcuts

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