bcns

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Sep = '/'

Variables

This section is empty.

Functions

func CheckName

func CheckName(name string) error

func Init added in v0.8.0

func Init(ctx context.Context, svc blobcache.Service, sch Namespace, volh blobcache.Handle) error

Init initializes a namespace in a Volume.

func IsValidName

func IsValidName(name string) bool

func Modify added in v0.8.0

func Modify(ctx context.Context, svc blobcache.Service, sch Namespace, volh blobcache.Handle, fn func(*Tx) error) error

Modify calls fn with a read-write transaction

func View added in v0.8.0

func View(ctx context.Context, svc blobcache.Service, sch Namespace, volh blobcache.Handle, fn func(*Tx) error) error

View calls fn with a read-only transaction

Types

type Client

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

Client gives access to the Namespace Client manages multi-volume interactions, see Tx for manipulating a single Namespace volume. The Client deals with paths, and the Tx deals with names.

func NewClient added in v0.8.0

func NewClient(svc blobcache.Service, root blobcache.OID) Client

func (*Client) CreateVolume added in v0.8.0

func (nsc *Client) CreateVolume(ctx context.Context, p string, spec blobcache.VolumeSpec) (blobcache.Handle, error)

func (*Client) CreateVolumeFrom added in v0.8.0

func (nsc *Client) CreateVolumeFrom(ctx context.Context, nsh blobcache.Handle, p string, spec blobcache.VolumeSpec) (blobcache.Handle, error)

CreateVolumeFrom creates a Volume starting from a specific namespace

func (*Client) Delete

func (nsc *Client) Delete(ctx context.Context, p string) error

func (*Client) Do added in v0.8.0

func (nsc *Client) Do(ctx context.Context, p string, modify bool, fn func(DoCtx) error) error

Do resolves as much of p as possible and then calls fn with the remaining name and a transaction open on the parent namespace.

func (*Client) FQP added in v0.8.0

func (nsc *Client) FQP(ctx context.Context, p string) (FQP, error)

FQP produces an FQP from p.

func (*Client) Get

func (nsc *Client) Get(ctx context.Context, p string, dst *Entry) (bool, error)

func (*Client) Init

func (nsc *Client) Init(ctx context.Context) error

Init initializes the root

func (*Client) List

func (nsc *Client) List(ctx context.Context, p string) ([]Entry, error)

func (*Client) ListNames

func (nsc *Client) ListNames(ctx context.Context, p string) ([]string, error)

func (*Client) Move added in v0.5.1

func (nsc *Client) Move(ctx context.Context, oldPath, newPath string) error

Move atomically renames an entry from oldPath to newPath within a namespace volume. The link token is preserved as-is. oldPath is resolved first, and newPath must share the resolved prefix, or an error is returned.

func (*Client) Open added in v0.8.0

func (nsc *Client) Open(ctx context.Context, p string, mask blobcache.ActionSet) (blobcache.Handle, error)

Open returns a handle to the object at p.

func (*Client) OpenFrom added in v0.8.0

func (nsc *Client) OpenFrom(ctx context.Context, nsh blobcache.Handle, p string, mask blobcache.ActionSet) (blobcache.Handle, error)

OpenFrom opens the path p from the namespace in nsh.

func (*Client) Put

func (nsc *Client) Put(ctx context.Context, p string, target blobcache.Handle, mask blobcache.ActionSet) error

func (*Client) Resolve added in v0.8.0

func (nsc *Client) Resolve(ctx context.Context, p string) (FQP, error)

Resolve returns a resolved path. A resolved path can be looked up in a single namespace volume, and does not require traversal. It may not be directly accessible with OpenFiat.

func (*Client) Root added in v0.8.0

func (nsc *Client) Root() blobcache.OID

func (*Client) SetDefaultSchema added in v0.8.0

func (nsc *Client) SetDefaultSchema(defaultSchema Namespace)

type DoCtx added in v0.8.0

type DoCtx struct {
	// Node is the node that owns the namespace Volume
	Node blobcache.NodeID
	// NS is the handle to the namespace Volume, that the transaction is for
	// This handle is for the the local node, not Node.
	NS blobcache.Handle
	// Tx is a transaction for maniuplating the namespace
	Tx *Tx
	// Prefix is the part of the path that was matched.
	Prefix string
	// Name is the remaining name within the namespace
	Name string
}

DoCtx is the context provided to the Do callback

type Entry

type Entry 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"`
	Secret blobcache.LTSecret  `json:"secret"`
}

Entry represents an entry in a namespace.

func (*Entry) LinkToken

func (ent *Entry) LinkToken() blobcache.LinkToken

type ErrNoMatch added in v0.8.0

type ErrNoMatch struct {
	// Name is the name which could not be matched
	Name string
}

func (*ErrNoMatch) Error added in v0.8.0

func (e *ErrNoMatch) Error() string

type FQP added in v0.8.0

type FQP struct {
	// Node is the node that the root namespace Volume is on.
	// If this is zero, then assume the local node.
	Node blobcache.NodeID
	// NS is a root/starting namespace
	NS blobcache.OID
	// Path is a slash separated path.
	Path string
}

FQP is a fully qualified path FQPs can be written as `{Node};{NSRoot}/{Path}` The zero NodeID is used to refer to the local node, and it can be ommitted.

func ParseFQP added in v0.8.0

func ParseFQP(x string) (FQP, error)

func (FQP) String added in v0.8.0

func (fqp FQP) String() string

type Linker added in v0.8.0

type Linker interface {
	bcsdk.Linker
	bcsdk.Unlinker
}

type Namespace

type Namespace interface {
	schema.Schema

	NSList(c schema.ROCtx) ([]Entry, 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(c schema.ROCtx, name string, dst *Entry) (bool, error)
	// Delete deletes the entry at the given name.
	// Delete is idempotent, and does not fail if the entry does not exist.
	NSDelete(c schema.RWCtx, name string) ([]byte, error)
	// Put performs an idempotent create or replace operation.
	NSPut(c schema.RWCtx, ent Entry) ([]byte, error)
}

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

func SchemaForVolume added in v0.8.0

func SchemaForVolume(ctx context.Context, svc blobcache.Service, nsvolh blobcache.Handle) (Namespace, error)

SchemaForVolume returns a Client configured to use the Namespace schema for the Volume If the Volume does not have a known Schema or the Schema is not Namespace then an error is returned.

type Tx added in v0.6.0

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

Tx is a transaction on a namespace

func NewFromTx added in v0.6.0

func NewFromTx(ctx context.Context, schema Namespace, tx *bcsdk.Tx) (Tx, error)

func NewTx added in v0.6.0

func NewTx(schema Namespace, ha blobcache.HashAlgo, s bcsdk.RWD, lnk Linker, cell []byte) Tx

func NewTxRO added in v0.6.0

func NewTxRO(schema Namespace, s bcsdk.RO, cell []byte) Tx

func (*Tx) AppendCell added in v0.8.0

func (tx *Tx) AppendCell(out []byte) []byte

func (*Tx) Create added in v0.8.0

func (tx *Tx) Create(ctx context.Context, name string, target blobcache.Handle, mask blobcache.ActionSet) error

Create creates a new entry at name only if there is no exising entry

func (*Tx) Delete added in v0.8.0

func (tx *Tx) Delete(ctx context.Context, name string) error

func (*Tx) Get added in v0.6.0

func (tx *Tx) Get(ctx context.Context, name string, dst *Entry) (bool, error)

func (*Tx) Init added in v0.8.0

func (tx *Tx) Init(ctx context.Context) error

func (*Tx) List added in v0.6.0

func (tx *Tx) List(ctx context.Context) ([]Entry, error)

func (*Tx) Match added in v0.8.0

func (tx *Tx) Match(ctx context.Context, p string) (Entry, string, error)

Match performs greedy prefix matching using / as possible split points. Match is the unit operation of path resolution. If no match is found ErrNoMatch is returned Match prefers entries with longer matching prefixes.

func (*Tx) Move added in v0.8.0

func (tx *Tx) Move(ctx context.Context, oldName, newName string) error

func (*Tx) Put added in v0.8.0

func (tx *Tx) Put(ctx context.Context, name string, target blobcache.Handle, mask blobcache.ActionSet) error

Directories

Path Synopsis
Package bcnstests implements a test suite for bcns
Package bcnstests implements a test suite for bcns

Jump to

Keyboard shortcuts

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