bcsdk

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: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDFromBytes added in v0.4.0

func CIDFromBytes(data []byte) (ret blobcache.CID)

func CreateOnSameHost

CreateOnSameHost creates a new subvolume on the same host as the base volume.

func ExistsSingle

func ExistsSingle(ctx context.Context, s interface {
	Exists(ctx context.Context, txh Handle, cids []CID, dst []bool) error
}, txh Handle, cid CID) (bool, error)

ExistsSingle is a convenience function for checking if a single CID exists using the slice based API.

func GetBytes added in v0.4.0

func GetBytes(ctx context.Context, src RO, cid blobcache.CID, hardMax int) ([]byte, error)

GetBytes gets a blob, but gracefully handles ErrTooSmall by resizing the buffer and retrying.

func Modify added in v0.0.2

func Modify(ctx context.Context, svc blobcache.Service, volh blobcache.Handle, fn func(s RW, root []byte) ([]byte, error)) error

Modify performs a modifying transaction on the volume.

func ModifyTx added in v0.0.2

func ModifyTx(ctx context.Context, svc blobcache.Service, volh blobcache.Handle, fn func(tx *Tx, root []byte) ([]byte, error)) error

func OpenURL added in v0.0.2

func URLFor added in v0.0.2

URLFor produces a URL for a Volume. If the Volume is a remote Volume than the OID of the Volume on the remote Node and the Endpoint of the remote Node will be included in the URL instead of the local Node.

func View added in v0.0.2

func View(ctx context.Context, svc blobcache.Service, volh blobcache.Handle, fn func(s RO, root []byte) error) error

func View1 added in v0.0.2

func View1[T any](ctx context.Context, svc blobcache.Service, volh blobcache.Handle, fn func(s RO, root []byte) (T, error)) (T, error)

Types

type ActionSet

type ActionSet = blobcache.ActionSet

type CID

type CID = blobcache.CID

type Cache added in v0.4.0

type Cache[T any] struct {
	// contains filtered or unexported fields
}

func NewCache added in v0.4.0

func NewCache[T any](size int, maxObjSize int, marshal Marshaler[T], parse Parser[T]) Cache[T]

func (*Cache[T]) Get added in v0.4.0

func (c *Cache[T]) Get(ctx context.Context, s RO, tr Ref[T]) (T, error)

func (*Cache[T]) Post added in v0.4.0

func (c *Cache[T]) Post(ctx context.Context, s WO, x T) (Ref[T], error)

type Handle

type Handle = blobcache.Handle

type Loader added in v0.0.2

type Loader interface {
	Load(ctx context.Context, dst *[]byte) error
}

type Marshaler added in v0.4.0

type Marshaler[T any] = func(x T, out []byte) []byte

Marshaler marshals a value of type T and appends it to out, returning the result

type OID

type OID = blobcache.OID

type Parser added in v0.4.0

type Parser[T any] = func(data []byte) (T, error)

Parser parses a type T from a slice of bytes

type RO added in v0.0.2

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

type RW interface {
	RO
	WO
}

RW is Read-Write Store methods

type RWD added in v0.0.2

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

RWD is Read-Write-Delete Store methods

type Ref added in v0.4.0

type Ref[T any] struct {
	// contains filtered or unexported fields
}

Ref is a typed blobcache.CID

func NewRef added in v0.4.0

func NewRef[T any](cid blobcache.CID) Ref[T]

func (*Ref[T]) CID added in v0.4.0

func (tr *Ref[T]) CID() blobcache.CID

func (*Ref[T]) Equals added in v0.4.0

func (tr *Ref[T]) Equals(other *Ref[T]) bool

func (*Ref[T]) IsZero added in v0.4.0

func (tr *Ref[T]) IsZero() bool

func (Ref[T]) Marshal added in v0.4.0

func (tr Ref[T]) Marshal(out []byte) []byte

func (*Ref[T]) Unmarshal added in v0.4.0

func (tr *Ref[T]) Unmarshal(data []byte) error

type Saver added in v0.0.2

type Saver interface {
	Save(ctx context.Context, src []byte) error
}

type Tx

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

Tx is a convenience type for managing a transaction within a Service.

func BeginTx

func BeginTx(ctx context.Context, s blobcache.Service, volH blobcache.Handle, txp blobcache.TxParams) (*Tx, error)

BeginTx begins a new transaction and returns the Tx type.

func NewTx

func NewTx(s blobcache.Service, h blobcache.Handle, hash blobcache.HashAlgo, maxSize int) *Tx

func (*Tx) Abort

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

func (*Tx) Commit

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

func (*Tx) Copy

func (tx *Tx) Copy(ctx context.Context, srcs []*Tx, cids []CID, success []bool) error

func (*Tx) Delete

func (tx *Tx) Delete(ctx context.Context, cids []CID) error

func (*Tx) Exists

func (tx *Tx) Exists(ctx context.Context, cids []CID, exists []bool) error

func (*Tx) Get

func (tx *Tx) Get(ctx context.Context, cid CID, buf []byte) (int, error)

func (*Tx) GetBytes added in v0.4.0

func (tx *Tx) GetBytes(ctx context.Context, cid CID, hardMax int) ([]byte, error)

func (*Tx) Hash

func (tx *Tx) Hash(data []byte) CID

func (*Tx) HashAlgo added in v0.4.0

func (tx *Tx) HashAlgo() blobcache.HashAlgo

func (*Tx) Inspect added in v0.4.0

func (tx *Tx) Inspect(ctx context.Context) (*blobcache.TxInfo, error)

func (*Tx) IsVisited

func (tx *Tx) IsVisited(ctx context.Context, cids []CID, yesVisited []bool) error

func (*Tx) KeepAlive

func (tx *Tx) KeepAlive(ctx context.Context) error
func (tx *Tx) Link(ctx context.Context, target blobcache.Handle, mask ActionSet) (*blobcache.LinkToken, error)

func (*Tx) Load

func (tx *Tx) Load(ctx context.Context, dst *[]byte) error

func (*Tx) MaxSize

func (tx *Tx) MaxSize() int

MaxSize is the largest Blob that could be accepted or returned.

func (*Tx) Post

func (tx *Tx) Post(ctx context.Context, data []byte) (CID, error)

func (*Tx) Save

func (tx *Tx) Save(ctx context.Context, src []byte) error
func (tx *Tx) Unlink(ctx context.Context, targets []blobcache.LinkToken) error

func (*Tx) Visit

func (tx *Tx) Visit(ctx context.Context, cids []CID) error
func (tx *Tx) VisitLinks(ctx context.Context, targets []blobcache.LinkToken) error

type TxSalt

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

TxSalt is a convenience type for managing a salted transaction within a Service.

func BeginTxSalt

func BeginTxSalt(ctx context.Context, s blobcache.Service, volH Handle, txp blobcache.TxParams) (*TxSalt, error)

BeginTxSalt is the salted variant of BeginTx.

func NewTxSalt

func NewTxSalt(s blobcache.Service, h Handle, hash blobcache.HashAlgo, maxSize int) *TxSalt

func (*TxSalt) Abort

func (tx *TxSalt) Abort(ctx context.Context) error

func (*TxSalt) Commit

func (tx *TxSalt) Commit(ctx context.Context) error

func (*TxSalt) Delete

func (tx *TxSalt) Delete(ctx context.Context, cid CID) error

func (*TxSalt) Exists

func (tx *TxSalt) Exists(ctx context.Context, cid CID) (bool, error)

func (*TxSalt) Get

func (tx *TxSalt) Get(ctx context.Context, cid CID, buf []byte, opts blobcache.GetOpts) (int, error)

func (*TxSalt) Hash

func (tx *TxSalt) Hash(salt *CID, data []byte) CID

func (*TxSalt) HashAlgo added in v0.4.0

func (tx *TxSalt) HashAlgo() blobcache.HashAlgo

func (*TxSalt) Inspect added in v0.4.0

func (tx *TxSalt) Inspect(ctx context.Context) (*blobcache.TxInfo, error)

func (*TxSalt) KeepAlive

func (tx *TxSalt) KeepAlive(ctx context.Context) error

func (*TxSalt) Load

func (tx *TxSalt) Load(ctx context.Context, dst *[]byte) error

func (*TxSalt) MaxSize

func (tx *TxSalt) MaxSize() int

func (*TxSalt) Post

func (tx *TxSalt) Post(ctx context.Context, data []byte, opts blobcache.PostOpts) (CID, error)

func (*TxSalt) Save

func (tx *TxSalt) Save(ctx context.Context, src []byte) error

type WO added in v0.0.2

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
}

type Watcher added in v0.4.0

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

Watcher watches a Volume for changes using a queue subscription. Changes are delivered as read-only transactions on the Out channel.

func NewWatcher added in v0.4.0

func NewWatcher(svc blobcache.Service, volh blobcache.Handle) (*Watcher, error)

NewWatcher creates a new Watcher that subscribes to volume changes. It creates a queue, subscribes it to the volume, and spawns a goroutine that sends a read-only Tx on the Out channel whenever the volume changes.

func (*Watcher) Close added in v0.4.0

func (w *Watcher) Close() error

Close stops the goroutine and closes the Out channel. It causes ForEach to return nil.

func (*Watcher) ForEach added in v0.4.0

func (w *Watcher) ForEach(ctx context.Context, fn func(tx *Tx) error) error

ForEach calls fn with a read-only transaction every time the volume changes. The Tx is closed after fn returns. If ForEach returns it will be because the context was cancelled or Close was called. The closed case returns nil, context errors are returned.

func (*Watcher) Out added in v0.4.0

func (w *Watcher) Out() <-chan *Tx

Out returns a receive-only channel that emits a read-only Tx whenever the volume changes. The caller is responsible for aborting the Tx when done with it.

Jump to

Keyboard shortcuts

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