bcsys

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

TODO: eventually remove this file, all errors should be in src/blobcache

Index

Constants

View Source
const (
	// DefaultVolumeTTL is the default time to live for a volume handle.
	DefaultVolumeTTL = 5 * time.Minute
	// DefaultTxTTL is the default time to live for a transaction handle.
	DefaultTxTTL = 1 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// MaxMaxBlobSize is the maximum size of the MaxSize volume parameter, for any local volume.
	MaxMaxBlobSize int64
}

type Env

type Env[LK any, LV LocalVolume[LK]] struct {
	Background context.Context
	PrivateKey ed25519.PrivateKey
	// Root is the root volume.
	// It will have the all-zero OID.
	Root volumes.Volume
	// MDS is where Volume metadata is stored.
	MDS         MetadataStore
	Policy      Policy
	PeerLocator PeerLocator
	MkSchema    schema.Factory

	// Local is the local volume system.
	Local      volumes.System[LVParams[LK], LV]
	GenerateLK func() (LK, error)
	LKToOID    func(LK) blobcache.OID
	OIDToLK    func(blobcache.OID) (LK, error)
}

type ErrNotAllowed

type ErrNotAllowed struct {
	Peer blobcache.PeerID
	// TODO: this should be a blobcache.ActionSet
	Action string
	Target blobcache.OID
}

func (ErrNotAllowed) Error

func (e ErrNotAllowed) Error() string

type LVParams

type LVParams[K any] struct {
	Key    K
	Params blobcache.VolumeConfig
}

LVParams are the parameters for a local volume

type LocalVolume

type LocalVolume[K any] interface {
	volumes.Volume
	Key() K
}

type MetadataStore

type MetadataStore interface {
	Put(ctx context.Context, oid blobcache.OID, entry VolumeEntry) error
	Delete(ctx context.Context, oid blobcache.OID) error
	Get(ctx context.Context, oid blobcache.OID, dst *VolumeEntry) (bool, error)
}

type PeerLocator

type PeerLocator interface {
	WhereIs(blobcache.PeerID) []netip.AddrPort
}

PeerLocator finds the address of peers

type Policy

type Policy interface {
	OpenFiat(peer blobcache.PeerID, target blobcache.OID) blobcache.ActionSet
	// CanCreate returns true if the peer can create a new volume.
	CanCreate(peer blobcache.PeerID) bool
	CanConnect(peer blobcache.PeerID) bool
}

type Service

type Service[LK any, LV LocalVolume[LK]] struct {
	// contains filtered or unexported fields
}

func New

func New[LK any, LV LocalVolume[LK]](env Env[LK, LV], cfg Config) *Service[LK, LV]

func (*Service[LV, LK]) Abort

func (s *Service[LV, LK]) Abort(ctx context.Context, txh blobcache.Handle) error

func (*Service[LK, LV]) AbortAll

func (s *Service[LK, LV]) AbortAll(ctx context.Context) error

AbortAll aborts all transactions.

func (*Service[LV, LK]) BeginTx

func (s *Service[LV, LK]) BeginTx(ctx context.Context, volh blobcache.Handle, txspec blobcache.TxParams) (*blobcache.Handle, error)

func (*Service[LK, LV]) Cleanup

func (s *Service[LK, LV]) Cleanup(ctx context.Context) ([]blobcache.OID, error)

Cleanup runs the full cleanup process. Cleanup removes expired handles, and cleans up any transactions, which are no longer referenced. It also removes volumes which are no longer referenced, and cleans up any in-memory resources for them. The dropped volumes are returned.

func (*Service[LK, LV]) CloneVolume

func (s *Service[LK, LV]) CloneVolume(ctx context.Context, caller *blobcache.PeerID, volh blobcache.Handle) (*blobcache.Handle, error)

func (*Service[LV, LK]) Commit

func (s *Service[LV, LK]) Commit(ctx context.Context, txh blobcache.Handle) error

func (*Service[LK, LV]) Copy

func (s *Service[LK, LV]) Copy(ctx context.Context, txh blobcache.Handle, srcTxns []blobcache.Handle, cids []blobcache.CID, out []bool) error

func (*Service[LK, LV]) CreateQueue

func (s *Service[LK, LV]) CreateQueue(ctx context.Context, host *blobcache.Endpoint, qspec blobcache.QueueSpec) (*blobcache.Handle, error)

func (*Service[LK, LV]) CreateVolume

func (s *Service[LK, LV]) CreateVolume(ctx context.Context, host *blobcache.Endpoint, vspec blobcache.VolumeSpec) (*blobcache.Handle, error)

func (*Service[LV, LK]) Delete

func (s *Service[LV, LK]) Delete(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID) error

func (*Service[LK, LV]) Drop

func (s *Service[LK, LV]) Drop(ctx context.Context, h blobcache.Handle) error

func (*Service[LK, LV]) Endpoint

func (s *Service[LK, LV]) Endpoint(ctx context.Context) (blobcache.Endpoint, error)

Endpoint blocks waiting for a node to be created (happens when Serve is running). And then returns the Endpoint for that Node.

func (*Service[LV, LK]) Exists

func (s *Service[LV, LK]) Exists(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, dst []bool) error

func (*Service[LV, LK]) Get

func (s *Service[LV, LK]) Get(ctx context.Context, txh blobcache.Handle, cid blobcache.CID, buf []byte, opts blobcache.GetOpts) (int, error)

func (*Service[LK, LV]) Insert

func (s *Service[LK, LV]) Insert(ctx context.Context, from *blobcache.Endpoint, qh blobcache.Handle, msgs []blobcache.Message) (*blobcache.InsertResp, error)

func (*Service[LK, LV]) InspectHandle

func (s *Service[LK, LV]) InspectHandle(ctx context.Context, h blobcache.Handle) (*blobcache.HandleInfo, error)

func (*Service[LK, LV]) InspectTx

func (s *Service[LK, LV]) InspectTx(ctx context.Context, txh blobcache.Handle) (*blobcache.TxInfo, error)

func (*Service[LV, LK]) InspectVolume

func (s *Service[LV, LK]) InspectVolume(ctx context.Context, h blobcache.Handle) (*blobcache.VolumeInfo, error)

func (*Service[LK, LV]) IsVisited

func (s *Service[LK, LV]) IsVisited(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, dst []bool) error

func (*Service[LK, LV]) KeepAlive

func (s *Service[LK, LV]) KeepAlive(ctx context.Context, hs []blobcache.Handle) error
func (s *Service[LK, LV]) Link(ctx context.Context, txh blobcache.Handle, target blobcache.Handle, mask blobcache.ActionSet) (*blobcache.LinkToken, error)

func (*Service[LV, LK]) Load

func (s *Service[LV, LK]) Load(ctx context.Context, txh blobcache.Handle, dst *[]byte) error

func (*Service[LK, LV]) LocalID

func (s *Service[LK, LV]) LocalID() blobcache.PeerID

func (*Service[LK, LV]) Next

func (s *Service[LK, LV]) Next(ctx context.Context, qh blobcache.Handle, buf []blobcache.Message, opts blobcache.NextOpts) (int, error)

func (*Service[LK, LV]) OpenFiat

func (s *Service[LK, LV]) OpenFiat(ctx context.Context, x blobcache.OID, mask blobcache.ActionSet) (*blobcache.Handle, error)

func (*Service[LK, LV]) OpenFrom

func (s *Service[LK, LV]) OpenFrom(ctx context.Context, base blobcache.Handle, ltok blobcache.LinkToken, mask blobcache.ActionSet) (*blobcache.Handle, error)

func (*Service[LK, LV]) Ping

func (s *Service[LK, LV]) Ping(ctx context.Context, ep blobcache.Endpoint) error

func (*Service[LV, LK]) Post

func (s *Service[LV, LK]) Post(ctx context.Context, txh blobcache.Handle, data []byte, opts blobcache.PostOpts) (blobcache.CID, error)

func (*Service[LV, LK]) Save

func (s *Service[LV, LK]) Save(ctx context.Context, txh blobcache.Handle, root []byte) error

func (*Service[LK, LV]) Serve

func (s *Service[LK, LV]) Serve(ctx context.Context, pc net.PacketConn) error

Serve handles requests from the network. Serve blocks untilt the context is cancelled, or Close is called. Cancelling the context will cause Run to return without an error. If Serve is *not* running, then remote volumes will not work, hosted on this Node or other Nodes.

func (*Service[LK, LV]) Share

func (*Service[LK, LV]) SubToVolume

func (s *Service[LK, LV]) SubToVolume(ctx context.Context, qh blobcache.Handle, volh blobcache.Handle) error
func (s *Service[LK, LV]) Unlink(ctx context.Context, txh blobcache.Handle, targets []blobcache.LinkToken) error

func (*Service[LK, LV]) Visit

func (s *Service[LK, LV]) Visit(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID) error
func (s *Service[LK, LV]) VisitLinks(ctx context.Context, txh blobcache.Handle, targets []blobcache.LinkToken) error

type VolumeEntry

type VolumeEntry struct {
	OID blobcache.OID

	MaxSize  int64
	Schema   blobcache.SchemaSpec
	HashAlgo blobcache.HashAlgo
	Salted   bool
	Backend  blobcache.VolumeBackend[blobcache.OID]

	Deps []blobcache.OID
}

func (VolumeEntry) Config

func (ve VolumeEntry) Config() blobcache.VolumeConfig

func (VolumeEntry) Info

func (ve VolumeEntry) Info() *blobcache.VolumeInfo

Jump to

Keyboard shortcuts

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