schema

package
v0.0.0-...-bc5d075 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package schema implements Schemas for blobcache volumes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	PrevCell  []byte
	NextCell  []byte
	PrevStore RO
	NextStore RO
}

Change is a change to a Volume.

type Constructor

type Constructor = func(params json.RawMessage, mkSchema Factory) (Schema, error)

Constructor is a function that constructs a Schema from its parameters.

type Container

type Container interface {
	Schema

	// ReadLinks returns a list of links for a given root.
	ReadLinks(ctx context.Context, s RO, root []byte, dst map[blobcache.OID]blobcache.ActionSet) error
}

Container is a Schema which can store Links to other volumes.

type Factory

type Factory = func(blobcache.SchemaSpec) (Schema, error)

Factory creates a Schema from a Spec.

type Link struct {
	// Target is the OID of the volume being referenced.
	Target blobcache.OID
	// Rights are the set of actions on the target, which are granted to the caller.
	Rights blobcache.ActionSet
}

Link is a reference from one volume to another.

type MemStore

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

MemStore is a simple in-memory store, useful for testing. It has the same store methods as a transaction on an unsalted volume.

func NewMem

func NewMem(hf blobcache.HashFunc, maxSize int) *MemStore

func (*MemStore) Delete

func (ms *MemStore) Delete(ctx context.Context, cids []blobcache.CID) error

func (*MemStore) Exists

func (ms *MemStore) Exists(ctx context.Context, cids []blobcache.CID, dst []bool) error

func (*MemStore) Get

func (ms *MemStore) Get(ctx context.Context, cid blobcache.CID, buf []byte) (int, error)

func (*MemStore) Hash

func (ms *MemStore) Hash(data []byte) blobcache.CID

func (*MemStore) Len

func (ms *MemStore) Len() int

func (*MemStore) MaxSize

func (ms *MemStore) MaxSize() int

func (*MemStore) Post

func (ms *MemStore) Post(ctx context.Context, data []byte) (blobcache.CID, error)

type None

type None struct{}

None is a Schema which does not impose any constraints on the contents of a volume.

func (None) ValidateChange

func (None) ValidateChange(ctx context.Context, change Change) error

type RO

type RO interface {
	Get(ctx context.Context, cid blobcache.CID, buf []byte) (int, error)
	Exists(ctx context.Context, cids []blobcache.CID, dst []bool) error
	Hash(data []byte) blobcache.CID
	MaxSize() int
}

RO is read-only Store methods

type RW

type RW interface {
	RO
	WO
}

RW is Read-Write Store methods

type RWD

type RWD interface {
	RW
	Delete(ctx context.Context, cids []blobcache.CID) error
}

RWD is Read-Write-Delete Store methods

func NewTestStore

func NewTestStore(t testing.TB) RWD

type Schema

type Schema interface {
	// ValidateChange returns nil if the state transition is valid.
	ValidateChange(ctx context.Context, change Change) error
}

Schema is the most general Schema type. All a Schema has to be able to do is validate the contents of a Volume.

func NoneConstructor

func NoneConstructor(_ json.RawMessage, _ Factory) (Schema, error)

type Spec

type Spec = blobcache.SchemaSpec

type WO

type WO interface {
	Post(ctx context.Context, data []byte) (blobcache.CID, error)
	Exists(ctx context.Context, cids []blobcache.CID, dst []bool) error
	Hash(data []byte) blobcache.CID
	MaxSize() int
}

Directories

Path Synopsis
Package basiccont implements a simple container for volumes.
Package basiccont implements a simple container for volumes.
Package basicns provides a simple namespace implementation.
Package basicns provides a simple namespace implementation.
package schematests provides a test suite for schemas.
package schematests provides a test suite for schemas.

Jump to

Keyboard shortcuts

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