ipfs-cluster: github.com/ipfs/ipfs-cluster/adder Index | Files | Directories

package adder

import "github.com/ipfs/ipfs-cluster/adder"

Package adder implements functionality to add content to IPFS daemons managed by the Cluster.


Package Files

adder.go util.go


var ErrBlockAdder = errors.New("failed to put block on all destinations")

ErrBlockAdder is returned when adding a to multiple destinations block fails on all of them.

var ErrDAGNotFound = errors.New("dagservice: block not found")

ErrDAGNotFound is returned whenever we try to get a block from the DAGService.

func BlockAllocate Uses

func BlockAllocate(ctx context.Context, rpc *rpc.Client, pinOpts api.PinOptions) ([]peer.ID, error)

BlockAllocate helps allocating blocks to peers.

func Pin Uses

func Pin(ctx context.Context, rpc *rpc.Client, pin *api.Pin) error

Pin helps sending local RPC pin requests.

type Adder Uses

type Adder struct {
    // contains filtered or unexported fields

Adder is used to add content to IPFS Cluster using an implementation of ClusterDAGService.

func New Uses

func New(ds ClusterDAGService, p *api.AddParams, out chan *api.AddedOutput) *Adder

New returns a new Adder with the given ClusterDAGService, add options and a channel to send updates during the adding process.

An Adder may only be used once.

func (*Adder) FromFiles Uses

func (a *Adder) FromFiles(ctx context.Context, f files.Directory) (cid.Cid, error)

FromFiles adds content from a files.Directory. The adder will no longer be usable after calling this method.

func (*Adder) FromMultipart Uses

func (a *Adder) FromMultipart(ctx context.Context, r *multipart.Reader) (cid.Cid, error)

FromMultipart adds content from a multipart.Reader. The adder will no longer be usable after calling this method.

type BaseDAGService Uses

type BaseDAGService struct {

BaseDAGService partially implements an ipld.DAGService. It provides the methods which are not needed by ClusterDAGServices (Get*, Remove*) so that they can save adding this code.

func (BaseDAGService) Get Uses

func (dag BaseDAGService) Get(ctx context.Context, key cid.Cid) (ipld.Node, error)

Get always returns errNotFound

func (BaseDAGService) GetMany Uses

func (dag BaseDAGService) GetMany(ctx context.Context, keys []cid.Cid) <-chan *ipld.NodeOption

GetMany returns an output channel that always emits an error

func (BaseDAGService) Remove Uses

func (dag BaseDAGService) Remove(ctx context.Context, key cid.Cid) error

Remove is a nop

func (BaseDAGService) RemoveMany Uses

func (dag BaseDAGService) RemoveMany(ctx context.Context, keys []cid.Cid) error

RemoveMany is a nop

type BlockAdder Uses

type BlockAdder struct {
    // contains filtered or unexported fields

BlockAdder implements "github.com/ipfs/go-ipld-format".NodeAdder. It helps sending nodes to multiple destinations, as long as one of them is still working.

func NewBlockAdder Uses

func NewBlockAdder(rpcClient *rpc.Client, dests []peer.ID) *BlockAdder

NewBlockAdder creates a BlockAdder given an rpc client and allocated peers.

func (*BlockAdder) Add Uses

func (ba *BlockAdder) Add(ctx context.Context, node ipld.Node) error

Add puts an ipld node to the allocated destinations.

func (*BlockAdder) AddMany Uses

func (ba *BlockAdder) AddMany(ctx context.Context, nodes []ipld.Node) error

AddMany puts multiple ipld nodes to allocated destinations.

type ClusterDAGService Uses

type ClusterDAGService interface {
    // Finalize receives the IPFS content root CID as
    // returned by the ipfs adder.
    Finalize(ctx context.Context, ipfsRoot cid.Cid) (cid.Cid, error)

ClusterDAGService is an implementation of ipld.DAGService plus a Finalize method. ClusterDAGServices can be used to provide Adders with a different add implementation.


adderutilsPackage adderutils provides some utilities for adding content to cluster.
ipfsaddPackage ipfsadd is a simplified copy of go-ipfs/core/coreunix/add.go
shardingPackage sharding implements a sharding ClusterDAGService places content in different shards while it's being added, creating a final Cluster DAG and pinning it.
singlePackage single implements a ClusterDAGService that chunks and adds content to cluster without sharding, before pinning it.

Package adder imports 16 packages (graph) and is imported by 4 packages. Updated 2020-05-27. Refresh now. Tools for package owners.