bclocal

package
v0.0.0-...-1ef88f4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package bclocal implements a local Blobcache service.

Index

Constants

View Source
const (
	DefaultVolumeTTL = 5 * time.Minute
	DefaultTxTTL     = 1 * time.Minute
)

Variables

This section is empty.

Functions

func SetupDB

func SetupDB(ctx context.Context, db *sqlx.DB) error

SetupDB idempotently applies all migrations to the database.

Types

type ACL

type ACL struct {
	// For now just blanket allow or don't.
	Owners []blobcache.PeerID
}

func (*ACL) CanCreate

func (acl *ACL) CanCreate(peer blobcache.PeerID, name string) bool

func (*ACL) CanDelete

func (acl *ACL) CanDelete(peer blobcache.PeerID, name string) bool

func (*ACL) CanLook

func (acl *ACL) CanLook(peer blobcache.PeerID, name string) bool

func (*ACL) CanTouch

func (acl *ACL) CanTouch(peer blobcache.PeerID, name string) bool

type Env

type Env struct {
	DB         *sqlx.DB
	PrivateKey ed25519.PrivateKey
	PacketConn net.PacketConn
	ACL        ACL
}

type ErrNotAllowed

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

func (ErrNotAllowed) Error

func (e ErrNotAllowed) Error() string

type PeerView

type PeerView struct {
	*Service
	Peer blobcache.PeerID
}

func (*PeerView) CreateVolume

func (pv *PeerView) CreateVolume(ctx context.Context, spec blobcache.VolumeSpec) (*blobcache.Handle, error)

func (*PeerView) DeleteEntry

func (pv *PeerView) DeleteEntry(ctx context.Context, namespace blobcache.Handle, name string) error

func (*PeerView) GetEntry

func (pv *PeerView) GetEntry(ctx context.Context, namespace blobcache.Handle, name string) (*blobcache.Entry, error)

func (*PeerView) ListNames

func (pv *PeerView) ListNames(ctx context.Context, namespace blobcache.Handle) ([]string, error)

func (*PeerView) Open

func (pv *PeerView) Open(ctx context.Context, x blobcache.OID) (*blobcache.Handle, error)

func (*PeerView) OpenAt

func (pv *PeerView) OpenAt(ctx context.Context, namespace blobcache.Handle, name string) (*blobcache.Handle, error)

func (*PeerView) PutEntry

func (pv *PeerView) PutEntry(ctx context.Context, namespace blobcache.Handle, name string, value blobcache.Handle) error

type Service

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

Service implements a blobcache.Service.

func New

func New(env Env) *Service

func NewTestService

func NewTestService(t testing.TB) *Service

NewTestService creates a service scoped to the life of the test.

func (*Service) Abort

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

func (*Service) Access

func (s *Service) Access(peer blobcache.PeerID) blobcache.Service

func (*Service) Await

func (s *Service) Await(ctx context.Context, cond blobcache.Conditions) error

func (*Service) BeginTx

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

func (*Service) Commit

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

func (*Service) CreateVolume

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

func (*Service) Delete

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

func (*Service) DeleteEntry

func (s *Service) DeleteEntry(ctx context.Context, ns blobcache.Handle, name string) error

func (*Service) Drop

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

func (*Service) Endpoint

func (s *Service) Endpoint(_ context.Context) (blobcache.Endpoint, error)

func (*Service) Exists

func (s *Service) Exists(ctx context.Context, txh blobcache.Handle, cid blobcache.CID) (bool, error)

func (*Service) Get

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

func (*Service) GetEntry

func (s *Service) GetEntry(ctx context.Context, ns blobcache.Handle, name string) (*blobcache.Entry, error)

func (*Service) InspectHandle

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

func (*Service) InspectVolume

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

func (*Service) KeepAlive

func (s *Service) KeepAlive(ctx context.Context, hs []blobcache.Handle) error

func (*Service) ListNames

func (s *Service) ListNames(ctx context.Context, ns blobcache.Handle) ([]string, error)

func (*Service) Load

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

func (*Service) Open

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

func (*Service) OpenAt

func (s *Service) OpenAt(ctx context.Context, base blobcache.Handle, name string) (*blobcache.Handle, error)

func (*Service) Post

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

func (*Service) PutEntry

func (s *Service) PutEntry(ctx context.Context, ns blobcache.Handle, name string, target blobcache.Handle) error

func (*Service) Run

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

type StoreID

type StoreID = int64

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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