schema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: GPL-3.0 Imports: 8 Imported by: 7

Documentation

Overview

Package schema implements Schemas for blobcache volumes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBlob added in v0.4.0

func CopyBlob(ctx context.Context, src RO, dst WO, cid bcsdk.CID) error

CopyBlob copies a blob from src to dst. TODO: check if src and dst are bcsdk.Tx and do an optimized copy.

func ExistsUnit added in v0.0.2

func ExistsUnit(ctx context.Context, s Exists, cid blobcache.CID) (bool, error)

Types

type Change

type Change struct {
	Prev, Next Value
}

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 Exists added in v0.0.2

type Exists interface {
	Exists(ctx context.Context, cids []blobcache.CID, dst []bool) error
}

type Factory

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

Factory creates a Schema from a Spec.

type Initializer added in v0.0.2

type Initializer interface {
	Init(ctx context.Context, s bcsdk.WO) ([]byte, error)
}

Initializer is an interface for Schemas which support initialization.

type KV added in v0.0.2

type KV[K, V any] interface {
	Put(ctx context.Context, s bcsdk.RW, root []byte, key K, value V) ([]byte, error)
	Get(ctx context.Context, s bcsdk.RO, root []byte, key K, dst *V) (bool, error)
	Delete(ctx context.Context, s bcsdk.RW, root []byte, key K) ([]byte, error)
}

KV is an interface for Schemas which support common Key-Value operations.

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 NewTestStore

func NewTestStore(t testing.TB) *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 = bcsdk.RO

type RW

type RW = bcsdk.RW

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 Syncer added in v0.0.2

type Syncer interface {
	// Sync ensures that all data transitively reachable from rootData
	// has been copied from rs to ws.
	Sync(ctx context.Context, rs bcsdk.RO, ws bcsdk.WO, rootData []byte) error
}

type Value added in v0.0.2

type Value struct {
	Cell  []byte
	Store bcsdk.RO
}

Value is the contents of a volume.

type VisitAll added in v0.0.2

type VisitAll interface {
	VisitAll(ctx context.Context, s bcsdk.RO, root []byte, visit func(cids []blobcache.CID, links []blobcache.LinkToken) error) error
}

type WO

type WO = bcsdk.WO

Directories

Path Synopsis
Package bcfuse implements a filesystem interface for blobcache.
Package bcfuse implements a filesystem interface for blobcache.
gitrh
package gitrh provides a Server implementation of the Git remote helper IPC protocol
package gitrh provides a Server implementation of the Git remote helper IPC protocol
Package hydra implements a Mergeable Schema
Package hydra implements a Mergeable Schema
Package jsonns provides a simple namespace implementation.
Package jsonns provides a simple namespace implementation.
Package radixkv implements a radix tree key-value store in a Blobcache volume.
Package radixkv implements a radix tree key-value store in a Blobcache volume.
package ledger implements an append-only ledger where state transitions can be verified
package ledger implements an append-only ledger where state transitions can be verified

Jump to

Keyboard shortcuts

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