Documentation
¶
Overview ¶
Package ipfs wraps the Docker API to provide an interface through which to interact with containerized network nodes
Index ¶
- func SwarmKey() (string, error)
- type Client
- func (c *Client) CreateNode(ctx context.Context, n *NodeInfo, opts NodeOpts) error
- func (c *Client) NodeStats(ctx context.Context, n *NodeInfo) (NodeStats, error)
- func (c *Client) Nodes(ctx context.Context) ([]*NodeInfo, error)
- func (c *Client) RemoveNode(ctx context.Context, network string) error
- func (c *Client) StopNode(ctx context.Context, n *NodeInfo) error
- func (c *Client) UpdateNode(ctx context.Context, n *NodeInfo) error
- func (c *Client) Watch(ctx context.Context) (<-chan Event, <-chan error)
- type Event
- type GoIPFSConfig
- type NodeClient
- type NodeInfo
- type NodeOpts
- type NodePorts
- type NodeResources
- type NodeStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the primary implementation of the NodeClient interface. Instantiate using ipfs.NewClient()
func (*Client) CreateNode ¶
CreateNode activates a new IPFS node
func (*Client) RemoveNode ¶
RemoveNode removes assets for given node
func (*Client) UpdateNode ¶
UpdateNode updates node configuration
type Event ¶
type Event struct {
Time int64 `json:"time"`
Status string `json:"status"`
Node NodeInfo `json:"node"`
}
Event is a node-related container event
type GoIPFSConfig ¶
GoIPFSConfig is a subset of go-ipfs's configuration structure
type NodeClient ¶
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 ¶
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 ¶
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 NodePorts ¶
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 ¶
type NodeResources struct {
DiskGB int `json:"disk"`
MemoryGB int `json:"memory"`
CPUs int `json:"cpus"`
}
NodeResources declares resource quotas for this node