blobstore

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package blobstore implements the filesystem storage and simpathy/want managment for ssb-blobs.

Index

Constants

View Source
const DefaultMaxSize = 5 * 1024 * 1024

DefaultMaxSize is 5 megabyte. Blobs that are biggere are not fetched.

Variables

View Source
var ErrBlobBlocked = errors.New("ssb: unable to receive blob correctly")

ErrBlobBlocked is returned if the want manager is unable to receive a blob after multiple tries

View Source
var ErrNoSuchBlob = errors.New("ssb: no such blob")

ErrNoSuchBlob is returned if the requested blob isn't available

Functions

func New

func New(basePath string) (ssb.BlobStore, error)

New creates a new BlobStore, storing it's blobs at the given path. This store is functionally equivalent to the javascript implementation and thus can share it's path. ie: 'ln -s ~/.ssb/blobs ~/.ssb-go/blobs' works to deduplicate the storage.

Types

type GetWithSize

type GetWithSize struct {
	Key refs.BlobRef `json:"key"`
	Max uint         `json:"max"`
}

GetWithSize is a muxrpc argument helper. It can be used to request a blob named _key_ with a different maximum size than the default.

type WantManager added in v0.2.1

type WantManager struct {
	*broadcasts.BlobWantsBroadcast
	// contains filtered or unexported fields
}

func NewWantManager

func NewWantManager(bs ssb.BlobStore, opts ...WantManagerOption) *WantManager

NewWantManager returns the configured WantManager, using bs for storage and opts to configure it.

func (*WantManager) AllWants added in v0.2.1

func (wmgr *WantManager) AllWants() []ssb.BlobWant

func (*WantManager) Close added in v0.2.1

func (wmgr *WantManager) Close() error

func (*WantManager) CreateWants added in v0.2.1

func (wmgr *WantManager) CreateWants(ctx context.Context, sink *muxrpc.ByteSink, edp muxrpc.Endpoint) luigi.Sink

func (*WantManager) EmitBlob added in v0.2.1

func (wmgr *WantManager) EmitBlob(n ssb.BlobStoreNotification) error

func (*WantManager) Want added in v0.2.1

func (wmgr *WantManager) Want(ref refs.BlobRef) error

func (*WantManager) WantWithDist added in v0.2.1

func (wmgr *WantManager) WantWithDist(ref refs.BlobRef, dist int64) error

func (*WantManager) Wants added in v0.2.1

func (wmgr *WantManager) Wants(ref refs.BlobRef) bool

type WantManagerOption

type WantManagerOption func(*WantManager) error

WantManagerOption is used to tune different aspects of the WantManager.

func WantWithContext

func WantWithContext(ctx context.Context) WantManagerOption

WantWithContext supplies a context to cancel its operations.

func WantWithLogger

func WantWithLogger(l log.Logger) WantManagerOption

WantWithLogger sets up the logger which is used for debug and info output.

func WantWithMaxSize

func WantWithMaxSize(sz uint) WantManagerOption

WantWithMaxSize can be used to change DefaultMaxSize

func WantWithMetrics

func WantWithMetrics(g metrics.Gauge, ctr metrics.Counter) WantManagerOption

WantWithMetrics setup the metrics counters and gauges to monitor the want manager.

type WantMsg

type WantMsg []ssb.BlobWant

WantMsg is an array of _wants_, a blob reference with a distance.

func (WantMsg) MarshalJSON

func (msg WantMsg) MarshalJSON() ([]byte, error)

MarshalJSON turns a BlobWant slice into one object. for example: { ref1:dist1, ref2:dist2, ... }

func (*WantMsg) UnmarshalJSON

func (msg *WantMsg) UnmarshalJSON(data []byte) error

UnmarshalJSON turns an object of {ref:dist, ...} relations into a slice of BlobWants.

Jump to

Keyboard shortcuts

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