schema

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: GPL-3.0 Imports: 10 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 CheckName added in v0.0.2

func CheckName(name string) error

func ExistsUnit added in v0.0.2

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

func IsValidName added in v0.0.2

func IsValidName(name string) bool

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

type NSClient struct {
	Service blobcache.Service
	Schema  Namespace
}

NSClient allows manipulation of namespace volumes.

func (*NSClient) CreateAt added in v0.0.2

func (nsc *NSClient) CreateAt(ctx context.Context, nsh blobcache.Handle, name string, spec blobcache.VolumeSpec) (*blobcache.Handle, error)

func (*NSClient) Delete added in v0.0.2

func (nsc *NSClient) Delete(ctx context.Context, nsh blobcache.Handle, name string) error

func (*NSClient) GC added in v0.0.2

func (nsc *NSClient) GC(ctx context.Context, volh blobcache.Handle) error

GC garbage collects the volume

func (*NSClient) Get added in v0.0.2

func (nsc *NSClient) Get(ctx context.Context, volh blobcache.Handle, name string, dst *NSEntry) (bool, error)

func (*NSClient) Init added in v0.0.2

func (nsc *NSClient) Init(ctx context.Context, volh blobcache.Handle) error

func (*NSClient) List added in v0.0.2

func (nsc *NSClient) List(ctx context.Context, volh blobcache.Handle) ([]NSEntry, error)

func (*NSClient) ListNames added in v0.0.2

func (nsc *NSClient) ListNames(ctx context.Context, volh blobcache.Handle) ([]string, error)

func (*NSClient) OpenAt added in v0.0.2

func (nsc *NSClient) OpenAt(ctx context.Context, nsh blobcache.Handle, name string, mask blobcache.ActionSet) (*blobcache.Handle, error)

func (*NSClient) Put added in v0.0.2

func (nsc *NSClient) Put(ctx context.Context, nsh blobcache.Handle, name string, volh blobcache.Handle, mask blobcache.ActionSet) error

type NSEntry added in v0.0.2

type NSEntry struct {
	// Name is the key for this entry within the namespace.
	Name string `json:"name"`
	// Target is the OID of the entry.
	Target blobcache.OID `json:"target"`
	// Rights is the set of rights for the entry.
	Rights blobcache.ActionSet `json:"rights"`
}

NSEntry represents an entry in a namespace.

func (ent *NSEntry) Link() Link

type Namespace added in v0.0.2

type Namespace interface {
	NSList(ctx context.Context, s bcsdk.RO, root []byte) ([]NSEntry, error)
	// NSGet retrieves the entry at the given name.
	// If the entry exists, it is returned in dst and true is returned.
	// If the entry does not exist, dst is not modified and false is returned.
	NSGet(ctx context.Context, s bcsdk.RO, root []byte, name string, dst *NSEntry) (bool, error)
	// Delete deletes the entry at the given name.
	// Delete is idempotent, and does not fail if the entry does not exist.
	NSDelete(ctx context.Context, s bcsdk.RW, root []byte, name string) ([]byte, error)
	// Put performs an idempotent create or replace operation.
	NSPut(ctx context.Context, s bcsdk.RW, root []byte, ent NSEntry) ([]byte, error)
}

Namespace is an interface for Schemas which support common Namespace operations.

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 Opener

type Opener interface {
	Schema

	OpenAs(ctx context.Context, s bcsdk.RO, root []byte, peer blobcache.PeerID) (blobcache.ActionSet, error)
}

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

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.OID) 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 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