Nexus: Index | Files | Directories

package ipfs

import ""

Package ipfs wraps the Docker API to provide an interface through which to interact with containerized network nodes


Package Files

client.go client_utils.go config.go doc.go docker.go ipfs.go key.go node.go utils.go

func SwarmKey Uses

func SwarmKey() (string, error)

SwarmKey generates a new swarm key

type Client Uses

type Client struct {
    // contains filtered or unexported fields

Client is the primary implementation of the NodeClient interface. Instantiate using ipfs.NewClient()

func (*Client) CreateNode Uses

func (c *Client) CreateNode(ctx context.Context, n *NodeInfo, opts NodeOpts) error

CreateNode activates a new IPFS node

func (*Client) NodeStats Uses

func (c *Client) NodeStats(ctx context.Context, n *NodeInfo) (NodeStats, error)

NodeStats retrieves statistics about the provided node

func (*Client) Nodes Uses

func (c *Client) Nodes(ctx context.Context) ([]*NodeInfo, error)

Nodes retrieves a list of active IPFS ndoes

func (*Client) RemoveNode Uses

func (c *Client) RemoveNode(ctx context.Context, network string) error

RemoveNode removes assets for given node

func (*Client) StopNode Uses

func (c *Client) StopNode(ctx context.Context, n *NodeInfo) error

StopNode shuts down an existing IPFS node

func (*Client) UpdateNode Uses

func (c *Client) UpdateNode(ctx context.Context, n *NodeInfo) error

UpdateNode updates node configuration

func (*Client) Watch Uses

func (c *Client) Watch(ctx context.Context) (<-chan Event, <-chan error)

Watch initializes a goroutine that tracks IPFS node events

type Event Uses

type Event struct {
    Time   int64    `json:"time"`
    Status string   `json:"status"`
    Node   NodeInfo `json:"node"`

Event is a node-related container event

type GoIPFSConfig Uses

type GoIPFSConfig struct {
    Identity struct {
        PeerID  string
        PrivKey string

GoIPFSConfig is a subset of go-ipfs's configuration structure

type NodeClient Uses

type NodeClient interface {
    Nodes(ctx context.Context) (nodes []*NodeInfo, err error)
    CreateNode(ctx context.Context, n *NodeInfo, opts NodeOpts) (err error)
    UpdateNode(ctx context.Context, n *NodeInfo) (err error)
    StopNode(ctx context.Context, n *NodeInfo) (err error)
    RemoveNode(ctx context.Context, network string) (err error)
    NodeStats(ctx context.Context, n *NodeInfo) (stats NodeStats, err error)
    Watch(ctx context.Context) (<-chan Event, <-chan error)

NodeClient provides an interface to the base Docker client for controlling IPFS nodes. It is implemented by ipfs.Client

func NewClient Uses

func NewClient(logger *zap.SugaredLogger, ipfsOpts config.IPFS) (NodeClient, error)

NewClient creates a new Docker Client from ENV values and negotiates the correct API version to use

type NodeInfo Uses

type NodeInfo struct {
    NetworkID string `json:"network_id"`
    JobID     string `json:"job_id"`

    Ports     NodePorts     `json:"ports"`
    Resources NodeResources `json:"resources"`

    // Metadata set by node client:
    // DockerID is the ID of the node's Docker container
    DockerID string `json:"docker_id"`
    // ContainerName is the name of the node's Docker container
    ContainerName string `json:"container_id"`
    // DataDir is the path to the directory holding all data relevant to this
    // IPFS node
    DataDir string `json:"data_dir"`
    // BootstrapPeers lists the peers this node was bootstrapped onto upon init
    BootstrapPeers []string `json:"bootstrap_peers"`

NodeInfo defines metadata about an IPFS node

type NodeOpts Uses

type NodeOpts struct {
    SwarmKey   []byte
    AutoRemove bool

NodeOpts declares options for starting up nodes

type NodePorts Uses

type NodePorts struct {
    Swarm   string `json:"swarm"`   // default: 4001
    API     string `json:"api"`     // default: 5001
    Gateway string `json:"gateway"` // default: 8080

NodePorts declares the exposed ports of an IPFS node

type NodeResources Uses

type NodeResources struct {
    DiskGB   int `json:"disk"`
    MemoryGB int `json:"memory"`
    CPUs     int `json:"cpus"`

NodeResources declares resource quotas for this node

type NodeStats Uses

type NodeStats struct {
    PeerID    string
    PeerKey   string
    Uptime    time.Duration
    DiskUsage int64
    Stats     interface{}

NodeStats provides details about a node container


internalPackage internal provides internal assets for the NodeManager
mockCode generated by counterfeiter.

Package ipfs imports 23 packages (graph) and is imported by 9 packages. Updated 2019-04-04. Refresh now. Tools for package owners.