blob

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 20 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 is the values too large to sit inside the entry that mentions them: where they live, how they are protected, and how a reference stands in for one.

Index

Constants

View Source
const Bytes = "application/octet-stream"

Bytes is the type of a blob nothing more is known about.

View Source
const Definition = "application/x-corbie-definition"

Definition is the type of a stored definition, the one kind of blob whose contents Corbie reads: it names its scripts and child definitions.

View Source
const StepLimit = 4 << 20

StepLimit is the largest blob a step may read or write. Work on larger ones is done by jobs.

Variables

View Source
var (
	// ErrAltered is a blob whose bytes are not the ones that were written.
	ErrAltered error = fault("the blob has been altered")
	// ErrCutShort is a blob that ends before its reference says it does.
	ErrCutShort error = fault("the blob has been cut short")
	// ErrGone is a blob that is not in the store.
	ErrGone error = fault("the blob is not in the store")
	// ErrTooLarge is a blob over the limit of whoever is reading it.
	ErrTooLarge error = fault("the blob is too large for a step")
	// ErrKey is a reference whose key is not one that opens a blob.
	ErrKey error = fault("the reference holds no key that opens a blob")
	// ErrDefinition is a blob typed as a stored definition that is not one.
	ErrDefinition error = fault("the stored definition is not readable")
)

Functions

func CopyAll

func CopyAll(ctx context.Context, s store.Store, v any, ctl, instance string) (any, error)

CopyAll gives a value in which every blob has been copied into an instance's record, with what stored definitions among them name. The copies are in the store before the value is returned.

func Made

func Made(at string) time.Time

Made is when a blob was named. A blob whose name carries no time, as one a step wrote has none, gives the zero time.

func NewKey

func NewKey() string

NewKey makes a key for a new blob.

func NewName

func NewName() string

NewName makes a name for a new blob. Like an instance's, it carries the time it was made: how old a blob is is read from its name, never from a file's times.

func ReadAll

func ReadAll(ctx context.Context, s store.Store, ref Ref, limit int64) ([]byte, error)

ReadAll reads the whole of a blob no larger than limit.

func Show

func Show(v any) any

Show gives a value as it is displayed to a person or handed to a model: each blob appears as its type, its size and the path to ask for it by, and no key is shown.

func Shown

func Shown(v any, fn func(path string, ref Ref) (any, error)) (any, error)

Shown is Walk for a value that is to be displayed or handed to a model: a reference written out as JSON inside a text is found too, and what fn gives for it is written in its place. A text is where the contents of a blob end up, and they may hold another blob's reference.

func TypeOf

func TypeOf(name string) string

TypeOf is the type of a blob made from a file with the name.

func Unusable

func Unusable(err error) bool

Unusable says whether an error is a blob's own: the blob cannot be used, and asking again will not change that.

func Walk

func Walk(v any, fn func(path string, ref Ref) (any, error)) (any, error)

Walk gives a copy of a value in which every reference has been replaced by what fn gives for it. The path says where in the value it was found. A reference written out inside a text is text, and is passed over.

Types

type Reader

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

A Reader reads a blob, any part of it, checking each piece before giving any byte of it.

func Open

func Open(ctx context.Context, s store.Store, ref Ref) (*Reader, error)

Open gives a reader of the blob a reference stands for.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

func (*Reader) ReadAt

func (r *Reader) ReadAt(p []byte, off int64) (int, error)

ReadAt reads from a place in the blob.

func (*Reader) Size

func (r *Reader) Size() int64

Size is the size of the blob's contents.

type Ref

type Ref struct {
	At   string `json:"$blob"` // the blob's name in the store
	Type string `json:"type"`
	Size int64  `json:"size"`
	Key  string `json:"key,omitzero"`
}

A Ref stands in for a blob wherever the blob is used. It says where the blob is, what type and size it is, and holds the key that opens it: holding the reference is the whole right to read the blob.

func AsRef

func AsRef(v any) (Ref, bool)

AsRef says whether a value is a reference, and gives it.

func Copy

func Copy(ctx context.Context, s store.Store, ref Ref, ctl, instance string) (Ref, error)

Copy puts a blob into another instance's record under the same name, without its bytes passing through, and gives the copy's reference. Done twice, it is done once.

func Find

func Find(v any, path string) (Ref, bool)

Find gives the reference at a path in a value, as Show named it.

func Named

func Named(ctx context.Context, s store.Store, def Ref) ([]Ref, error)

Named gives the blobs a stored definition names, and those the definitions among them name, each resolved to where it is.

func Refs

func Refs(v any) []Ref

Refs gives every reference in a value.

func Write

func Write(ctx context.Context, s store.Store, at, typ, key string, r io.Reader) (Ref, error)

Write stores a new blob under the name at, reading its contents from r, and gives its reference. The blob is complete in the store before the reference exists.

func (Ref) Beside

func (r Ref) Beside(inner Ref) Ref

Beside resolves a reference found inside a stored definition.

func (Ref) Format

func (r Ref) Format(f fmt.State, verb rune)

Format keeps the key out of every way of printing a reference.

func (Ref) Instance

func (r Ref) Instance() string

Instance is the instance whose record the blob lives in.

func (Ref) Local

func (r Ref) Local() Ref

Local is the reference as a stored definition in the same record names it.

func (Ref) String

func (r Ref) String() string

String shows a reference without its key.

func (Ref) Value

func (r Ref) Value() any

Value is the reference as it sits inside a value.

Jump to

Keyboard shortcuts

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