Documentation ¶
Overview ¶
Package api holds declarations for types used in ipfs-cluster APIs to make them re-usable across differen tools. This include RPC API "Serial[izable]" versions for types. The Go API uses natives types, while RPC API, REST APIs etc use serializable types (i.e. json format). Conversion methods exists between types.
Note that all conversion methods ignore any parsing errors. All values must be validated first before initializing any of the types defined here.
Index ¶
- Constants
- func Libp2pMultiaddrSplit(addr ma.Multiaddr) (peer.ID, ma.Multiaddr, error)
- func MustLibp2pMultiaddrJoin(addr ma.Multiaddr, p peer.ID) ma.Multiaddr
- func PeersToStrings(peers []peer.ID) []string
- func StringsToPeers(strs []string) []peer.ID
- type Alert
- type ConnectGraph
- type ConnectGraphSerial
- type Error
- type GlobalPinInfo
- type GlobalPinInfoSerial
- type ID
- type IDSerial
- type IPFSID
- type IPFSIDSerial
- type IPFSPinStatus
- type Metric
- type MultiaddrSerial
- type MultiaddrsSerial
- type Pin
- type PinInfo
- type PinInfoSerial
- type PinSerial
- type SwarmPeers
- type SwarmPeersSerial
- type TrackerStatus
- type Version
Constants ¶
const ( // IPFSStatus should never take this value TrackerStatusBug = iota // The cluster node is offline or not responding TrackerStatusClusterError // An error occurred pinning TrackerStatusPinError // An error occurred unpinning TrackerStatusUnpinError // The IPFS daemon has pinned the item TrackerStatusPinned // The IPFS daemon is currently pinning the item TrackerStatusPinning // The IPFS daemon is currently unpinning the item TrackerStatusUnpinning // The IPFS daemon is not pinning the item TrackerStatusUnpinned // The IPFS daemon is not pinning the item but it is being tracked TrackerStatusRemote // The item has been queued for pinning on the IPFS daemon TrackerStatusPinQueued // The item has been queued for unpinning on the IPFS daemon TrackerStatusUnpinQueued )
TrackerStatus values
const ( IPFSPinStatusBug = iota IPFSPinStatusError IPFSPinStatusDirect IPFSPinStatusRecursive IPFSPinStatusIndirect IPFSPinStatusUnpinned )
IPFSPinStatus values
Variables ¶
This section is empty.
Functions ¶
func Libp2pMultiaddrSplit ¶ added in v0.3.5
Libp2pMultiaddrSplit takes a LibP2P multiaddress (/<multiaddr>/ipfs/<peerID>) and decapsulates it, parsing the peer ID. Returns an error if there is any problem (for example, the provided address not being a Libp2p one).
func MustLibp2pMultiaddrJoin ¶ added in v0.3.5
MustLibp2pMultiaddrJoin takes a LibP2P multiaddress and a peer ID and encapsulates a new /ipfs/<peerID> address. It will panic if the given peer ID is bad.
func PeersToStrings ¶ added in v0.3.1
PeersToStrings IDB58Encodes a list of peers.
func StringsToPeers ¶ added in v0.3.1
StringsToPeers decodes peer.IDs from strings.
Types ¶
type ConnectGraph ¶ added in v0.3.3
type ConnectGraph struct { ClusterID peer.ID IPFSLinks map[peer.ID][]peer.ID // ipfs to ipfs links ClusterLinks map[peer.ID][]peer.ID // cluster to cluster links ClustertoIPFS map[peer.ID]peer.ID // cluster to ipfs links }
ConnectGraph holds information about the connectivity of the cluster
To read, traverse the keys of ClusterLinks. Each such id is one of the peers of the "ClusterID" peer running the query. ClusterLinks[id] in turn lists the ids that peer "id" sees itself connected to. It is possible that id is a peer of ClusterID, but ClusterID can not reach id over rpc, in which case ClusterLinks[id] == [], as id's view of its connectivity can not be retrieved. Iff there was an error reading the IPFSID of the peer then id will not be a key of ClustertoIPFS or IPFSLinks. Finally iff id is a key of ClustertoIPFS then id will be a key of IPFSLinks. In the event of a SwarmPeers error IPFSLinks[id] == [].
func (ConnectGraph) ToSerial ¶ added in v0.3.3
func (cg ConnectGraph) ToSerial() ConnectGraphSerial
ToSerial converts a ConnectGraph to its Go-serializable version
type ConnectGraphSerial ¶ added in v0.3.3
type ConnectGraphSerial struct { ClusterID string IPFSLinks map[string][]string `json:"ipfs_links"` ClusterLinks map[string][]string `json:"cluster_links"` ClustertoIPFS map[string]string `json:"cluster_to_ipfs"` }
ConnectGraphSerial is the serializable ConnectGraph counterpart for RPC requests
func (ConnectGraphSerial) ToConnectGraph ¶ added in v0.3.3
func (cgs ConnectGraphSerial) ToConnectGraph() ConnectGraph
ToConnectGraph converts a ConnectGraphSerial to a ConnectGraph
type GlobalPinInfo ¶
GlobalPinInfo contains cluster-wide status information about a tracked Cid, indexed by cluster peer.
func (GlobalPinInfo) ToSerial ¶
func (gpi GlobalPinInfo) ToSerial() GlobalPinInfoSerial
ToSerial converts a GlobalPinInfo to its serializable version.
type GlobalPinInfoSerial ¶
type GlobalPinInfoSerial struct { Cid string `json:"cid"` PeerMap map[string]PinInfoSerial `json:"peer_map"` }
GlobalPinInfoSerial is the serializable version of GlobalPinInfo.
func (GlobalPinInfoSerial) ToGlobalPinInfo ¶
func (gpis GlobalPinInfoSerial) ToGlobalPinInfo() GlobalPinInfo
ToGlobalPinInfo converts a GlobalPinInfoSerial to its native version.
type ID ¶
type ID struct { ID peer.ID Addresses []ma.Multiaddr ClusterPeers []peer.ID ClusterPeersAddresses []ma.Multiaddr Version string Commit string RPCProtocolVersion protocol.ID Error string IPFS IPFSID Peername string }
ID holds information about the Cluster peer
type IDSerial ¶
type IDSerial struct { ID string `json:"id"` Addresses MultiaddrsSerial `json:"addresses"` ClusterPeers []string `json:"cluster_peers"` ClusterPeersAddresses MultiaddrsSerial `json:"cluster_peers_addresses"` Version string `json:"version"` Commit string `json:"commit"` RPCProtocolVersion string `json:"rpc_protocol_version"` Error string `json:"error"` IPFS IPFSIDSerial `json:"ipfs"` Peername string `json:"peername"` }
IDSerial is the serializable ID counterpart for RPC requests
type IPFSID ¶
IPFSID is used to store information about the underlying IPFS daemon
func (*IPFSID) ToSerial ¶
func (id *IPFSID) ToSerial() IPFSIDSerial
ToSerial converts IPFSID to a go serializable object
type IPFSIDSerial ¶
type IPFSIDSerial struct { ID string `json:"id"` Addresses MultiaddrsSerial `json:"addresses"` Error string `json:"error"` }
IPFSIDSerial is the serializable IPFSID for RPC requests
func (*IPFSIDSerial) ToIPFSID ¶
func (ids *IPFSIDSerial) ToIPFSID() IPFSID
ToIPFSID converts an IPFSIDSerial to IPFSID
type IPFSPinStatus ¶
type IPFSPinStatus int
IPFSPinStatus represents the status of a pin in IPFS (direct, recursive etc.)
func IPFSPinStatusFromString ¶
func IPFSPinStatusFromString(t string) IPFSPinStatus
IPFSPinStatusFromString parses a string and returns the matching IPFSPinStatus.
func (IPFSPinStatus) IsPinned ¶
func (ips IPFSPinStatus) IsPinned() bool
IsPinned returns true if the status is Direct or Recursive
type Metric ¶
type Metric struct { Name string Peer peer.ID // filled-in by Cluster. Value string Expire int64 // UnixNano Valid bool // if the metric is not valid it will be discarded }
Metric transports information about a peer.ID. It is used to decide pin allocations by a PinAllocator. IPFS cluster is agnostic to the Value, which should be interpreted by the PinAllocator.
type MultiaddrSerial ¶
type MultiaddrSerial string
MultiaddrSerial is a Multiaddress in a serializable form
func MultiaddrToSerial ¶
func MultiaddrToSerial(addr ma.Multiaddr) MultiaddrSerial
MultiaddrToSerial converts a Multiaddress to its serializable form
func (MultiaddrSerial) ToMultiaddr ¶
func (addrS MultiaddrSerial) ToMultiaddr() ma.Multiaddr
ToMultiaddr converts a serializable Multiaddress to its original type. All errors are ignored.
type MultiaddrsSerial ¶
type MultiaddrsSerial []MultiaddrSerial
MultiaddrsSerial is an array of Multiaddresses in serializable form
func MultiaddrsToSerial ¶
func MultiaddrsToSerial(addrs []ma.Multiaddr) MultiaddrsSerial
MultiaddrsToSerial converts a slice of Multiaddresses to its serializable form.
func (MultiaddrsSerial) ToMultiaddrs ¶
func (addrsS MultiaddrsSerial) ToMultiaddrs() []ma.Multiaddr
ToMultiaddrs converts MultiaddrsSerial back to a slice of Multiaddresses
type Pin ¶ added in v0.0.6
type Pin struct { Cid *cid.Cid Name string Allocations []peer.ID ReplicationFactorMin int ReplicationFactorMax int Recursive bool }
Pin is an argument that carries a Cid. It may carry more things in the future.
func PinCid ¶ added in v0.0.6
PinCid is a shorcut to create a Pin only with a Cid. Default is for pin to be recursive
type PinInfo ¶
PinInfo holds information about local pins.
func (PinInfo) ToSerial ¶
func (pi PinInfo) ToSerial() PinInfoSerial
ToSerial converts a PinInfo to its serializable version.
type PinInfoSerial ¶
type PinInfoSerial struct { Cid string `json:"cid"` Peer string `json:"peer"` Status string `json:"status"` TS string `json:"timestamp"` Error string `json:"error"` }
PinInfoSerial is a serializable version of PinInfo. information is marked as
func (PinInfoSerial) ToPinInfo ¶
func (pis PinInfoSerial) ToPinInfo() PinInfo
ToPinInfo converts a PinInfoSerial to its native version.
type PinSerial ¶ added in v0.0.6
type PinSerial struct { Cid string `json:"cid"` Name string `json:"name"` Allocations []string `json:"allocations"` ReplicationFactorMin int `json:"replication_factor_min"` ReplicationFactorMax int `json:"replication_factor_max"` Recursive bool `json:"recursive"` }
PinSerial is a serializable version of Pin
type SwarmPeers ¶ added in v0.3.3
SwarmPeers lists an ipfs daemon's peers
func (SwarmPeers) ToSerial ¶ added in v0.3.3
func (swarm SwarmPeers) ToSerial() SwarmPeersSerial
ToSerial converts SwarmPeers to its Go-serializeable version
type SwarmPeersSerial ¶ added in v0.3.3
type SwarmPeersSerial []string
SwarmPeersSerial is the serialized form of SwarmPeers for RPC use
func (SwarmPeersSerial) ToSwarmPeers ¶ added in v0.3.3
func (swarmS SwarmPeersSerial) ToSwarmPeers() SwarmPeers
ToSwarmPeers converts a SwarmPeersSerial object to SwarmPeers.
type TrackerStatus ¶
type TrackerStatus int
TrackerStatus represents the status of a tracked Cid in the PinTracker
func TrackerStatusFromString ¶
func TrackerStatusFromString(str string) TrackerStatus
TrackerStatusFromString parses a string and returns the matching TrackerStatus value.
func (TrackerStatus) String ¶
func (st TrackerStatus) String() string
String converts a TrackerStatus into a readable string.