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
- Variables
- func CopyAll(ctx context.Context, s store.Store, v any, ctl, instance string) (any, error)
- func Made(at string) time.Time
- func NewKey() string
- func NewName() string
- func ReadAll(ctx context.Context, s store.Store, ref Ref, limit int64) ([]byte, error)
- func Show(v any) any
- func Shown(v any, fn func(path string, ref Ref) (any, error)) (any, error)
- func TypeOf(name string) string
- func Unusable(err error) bool
- func Walk(v any, fn func(path string, ref Ref) (any, error)) (any, error)
- type Reader
- type Ref
- func AsRef(v any) (Ref, bool)
- func Copy(ctx context.Context, s store.Store, ref Ref, ctl, instance string) (Ref, error)
- func Find(v any, path string) (Ref, bool)
- func Named(ctx context.Context, s store.Store, def Ref) ([]Ref, error)
- func Refs(v any) []Ref
- func Write(ctx context.Context, s store.Store, at, typ, key string, r io.Reader) (Ref, error)
Constants ¶
const Bytes = "application/octet-stream"
Bytes is the type of a blob nothing more is known about.
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.
const StepLimit = 4 << 20
StepLimit is the largest blob a step may read or write. Work on larger ones is done by jobs.
Variables ¶
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 ¶
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 ¶
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 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 Show ¶
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 ¶
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.
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.
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 Copy ¶
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 Named ¶
Named gives the blobs a stored definition names, and those the definitions among them name, each resolved to where it is.
func Write ¶
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.