bclocal

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: 40 Imported by: 0

Documentation

Overview

Package bclocal implements a local Blobcache service.

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

	// MaxMaxBlobSize is the maximum value that a Volume's max size can be set to.
	MaxMaxBlobSize = 1 << 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllOrNothingPolicy

type AllOrNothingPolicy struct {
	Allow []blobcache.PeerID
}

AllOrNothingPolicy is a policy that allows or disallows all actions for all peers.

func (*AllOrNothingPolicy) CanConnect

func (p *AllOrNothingPolicy) CanConnect(peer blobcache.PeerID) bool

func (*AllOrNothingPolicy) CanCreate

func (p *AllOrNothingPolicy) CanCreate(peer blobcache.PeerID) bool

func (*AllOrNothingPolicy) OpenFiat

type Config

type Config struct {
	// When set to true, the service will not sync the database and blob directory.
	NoSync bool
}

Config contains configuration for the service. Config{} works fine. You don't need to worry about anything in here.

type Env

type Env struct {
	Background context.Context
	// StateDir is the directory where all the state is stored.
	StateDir string
	// PrivateKey determines the node's identity.
	// It must be provided if PacketConn is set.
	PrivateKey ed25519.PrivateKey
	// MkSchema is the factory function to create a schema.
	MkSchema schema.Factory
	// Root is the spec to use for the root volume.
	Root blobcache.VolumeSpec
	// Policy control network access to the service.
	Policy Policy
}

func NewTestEnv

func NewTestEnv(t testing.TB) Env

NewTestEnv creates a test environment. It uses: - t.TempDir() to create a temporary directory - creates a UDP socket on a random port. All the resources are cleaned up when the test is done.

type ErrNotAllowed

type ErrNotAllowed struct {
	Peer   blobcache.PeerID
	Action string
	Target blobcache.OID
}

func (ErrNotAllowed) Error

func (e ErrNotAllowed) Error() string

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 struct {
	// contains filtered or unexported fields
}

Service implements a blobcache.Service.

func New

func New(env Env, cfg Config) (*Service, error)

func NewTestService

func NewTestService(t testing.TB) *Service

NewTestService creates a service scoped to the life of the test. It calls NewTestEnv and NewTestServiceFromEnv

func NewTestServiceFromEnv

func NewTestServiceFromEnv(t testing.TB, env Env) *Service

NewTestServiceFromEnv creates a service from an environment. It runs the service in the background and forcibly aborts all transactions when the test is done.

func (*Service) Abort

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

func (*Service) AbortAll

func (s *Service) AbortAll(ctx context.Context) error

AbortAll aborts all transactions.

func (*Service) BeginTx

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

func (*Service) Cleanup

func (s *Service) Cleanup(ctx context.Context) error

Cleanup runs the full cleanup process. This method is called periodically by Run, but it can also be called manually.

func (*Service) CloneVolume

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

func (*Service) Close

func (s *Service) Close() error

func (*Service) Commit

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

func (*Service) Copy

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

func (*Service) CreateQueue

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

func (*Service) CreateVolume

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

func (*Service) Delete

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

func (*Service) Drop

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

func (*Service) Endpoint

func (s *Service) 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) Exists

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

func (*Service) Get

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

func (*Service) Insert

func (*Service) InspectHandle

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

func (*Service) InspectTx

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

func (*Service) InspectVolume

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

func (*Service) IsVisited

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

func (*Service) KeepAlive

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

func (*Service) Load

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

func (*Service) LocalID

func (s *Service) LocalID() blobcache.PeerID

func (*Service) Next

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

func (*Service) OpenFiat

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

func (*Service) OpenFrom

func (*Service) Ping

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

func (*Service) Post

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

func (*Service) Save

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

func (*Service) Serve

func (s *Service) 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) Share

func (*Service) SubToVolume

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

func (*Service) Visit

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

Directories

Path Synopsis
internal
blobman/shard
Package shard implements a single Shard in the database A Shard is a single directory on disk, called the Shard's "root".
Package shard implements a single Shard in the database A Shard is a single directory on disk, called the Shard's "root".
dbtab
package dbtab contains constant IDs for each Table
package dbtab contains constant IDs for each Table
pdb
package pdb has utilities for working with the Pebble database.
package pdb has utilities for working with the Pebble database.

Jump to

Keyboard shortcuts

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