blobcache

package
v0.0.0-...-817062f Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const MaxSize = stores.MaxSize

MaxSize is the maximum blob size

View Source
const (
	StatusOK = "OK"
)

Variables

View Source
var (
	ErrPinSetNotFound = errors.New("pinset not found")
	ErrDataNotFound   = cadata.ErrNotFound
)

Functions

func Hash

func Hash(x []byte) cadata.ID

Hash is the hash function used to compute cadata.IDs

func NewStore

func NewStore(bc Service, pinSet Handle) cadata.Store

NewStore returns a cadata.Store

Types

type Entry

type Entry = dirserv.Entry

type Handle

type Handle = dirserv.Handle

type Node

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

func NewNode

func NewNode(params Params) *Node

func (*Node) Add

func (node *Node) Add(ctx context.Context, psh Handle, id cadata.ID) error

Add implements Service

func (*Node) CreateDir

func (n *Node) CreateDir(ctx context.Context, h Handle, name string) (*Handle, error)

CreateDir implements Service

func (*Node) CreatePinSet

func (n *Node) CreatePinSet(ctx context.Context, h Handle, name string, opts PinSetOptions) (*Handle, error)

CreatePinSet implements Service

func (*Node) Delete

func (n *Node) Delete(ctx context.Context, psh Handle, id cadata.ID) error

func (*Node) DeleteEntry

func (n *Node) DeleteEntry(ctx context.Context, h Handle, name string) error

DeleteEntry implements Service

func (*Node) Exists

func (n *Node) Exists(ctx context.Context, psh Handle, id cadata.ID) (bool, error)

func (*Node) Get

func (n *Node) Get(ctx context.Context, psh Handle, id cadata.ID, buf []byte) (int, error)

func (*Node) GetPinSet

func (n *Node) GetPinSet(ctx context.Context, psh Handle) (*PinSet, error)

GetPinSet implements Service

func (*Node) List

func (node *Node) List(ctx context.Context, psh Handle, span cadata.Span, ids []cadata.ID) (n int, err error)

func (*Node) ListEntries

func (n *Node) ListEntries(ctx context.Context, h Handle) ([]Entry, error)

ListEntries

func (*Node) MaxSize

func (n *Node) MaxSize() int

func (*Node) Open

func (n *Node) Open(ctx context.Context, h Handle, p []string) (*Handle, error)

Open implements Service

func (*Node) Post

func (n *Node) Post(ctx context.Context, psh Handle, data []byte) (cadata.ID, error)

func (*Node) Root

func (n *Node) Root() Handle

func (*Node) WaitOK

func (n *Node) WaitOK(ctx context.Context, psh Handle) error

type Params

type Params struct {
	// DB is the database to use for Directories, PinSets and other metadata. (REQUIRED)
	DB bcdb.DB
	// Primary is the Primary store (REQUIRED)
	Primary cadata.Store
	// PrivateKey is a private key used by the node for secure connections and for deriving a unique identifer. (REQUIRED)
	PrivateKey inet256.PrivateKey

	// AuxStores are auxillary stores.
	AuxStores []StoreSpec

	// INET256 is the INET256 service to use. (REQUIRED if len(Peers) > 0 )
	INET256 inet256.Service
	// Peers contains information about other Blobcache nodes to connect to.
	Peers []PeerInfo

	Logger *logrus.Logger

	// The maximum number of blobs to store in the Primary if any.
	MaxCount int64
}

func NewMemParams

func NewMemParams() Params

type PeerInfo

type PeerInfo struct {
	ID         inet256.ID
	QuotaCount uint64
}

type PinSet

type PinSet struct {
	Status string `json:"status"`
	Count  uint64 `json:"count"`
}

type PinSetID

type PinSetID uint64

func (PinSetID) HexString

func (id PinSetID) HexString() string

type PinSetOptions

type PinSetOptions struct {
}

type Service

type Service interface {
	// CreateDir creates a directory below handle
	CreateDir(ctx context.Context, h Handle, name string) (*Handle, error)
	// Open returns a handle to an object
	Open(ctx context.Context, h Handle, p []string) (*Handle, error)
	// ListEntries lists the entries in the directory which h points to.
	ListEntries(ctx context.Context, h Handle) ([]Entry, error)
	// DeleteEntry ensures that there is no entry at name
	DeleteEntry(ctx context.Context, h Handle, name string) error

	// CreatePinSet creates a PinSet with the provided options and returns a handle to it.
	CreatePinSet(ctx context.Context, h Handle, name string, opts PinSetOptions) (*Handle, error)
	// GetPinSet returns information about the PinSet
	GetPinSet(ctx context.Context, h Handle) (*PinSet, error)

	// Add adds data to the PinSet by ID.
	Add(ctx context.Context, pinset Handle, id cadata.ID) error
	// Delete removes data from the PinSet by ID.
	Delete(ctx context.Context, pinset Handle, id cadata.ID) error
	// Post adds data to a PinSet and returns the ID.
	Post(ctx context.Context, pinset Handle, data []byte) (cadata.ID, error)
	// Get retrieves data from the PinSet and returns the ID.
	Get(ctx context.Context, pinset Handle, id cadata.ID, buf []byte) (int, error)
	// Exists returns whether the PinSet contains ID
	Exists(ctx context.Context, pinset Handle, id cadata.ID) (bool, error)
	// List lists the ids in the pinSet.
	List(ctx context.Context, pinSet Handle, span cadata.Span, ids []cadata.ID) (n int, err error)
	// WaitOK waits until the pinSet is status is OK.
	// This means that all the blobs in the pinSet are correctly replicated according to the pinset's config.
	WaitOK(ctx context.Context, pinSet Handle) error

	// MaxSize returns the maximum blob size
	MaxSize() int
}

Service is the API exposed by either a blobcache client, or inmemory node.

type Source

type Source = interface {
	cadata.Exister
	cadata.Getter
}

type Store

type Store = cadata.Store

type StoreSpec

type StoreSpec struct {
	Name       string
	Cost       control.Cost
	BatchSize  int
	BatchDelay int
	Target     control.Target
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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