ipfscluster程序包
import "github.com/ipfs/ipfs-cluster"
ipfscluster包为IPFS deamon实现了一个包装器,它允许协调几个IPFS节点之间的ping操作。
IPFS集群使用go-libp2p-raft来保持不同集群对等节点之间的共享状态。它还使用LibP2P实现其不同组件之间的通信,这些组件执行不同的任务,如管理底层IPFS守护程序,或提供外部控制API。
索引 ¶
- 常量
- 变量
- func DecodeClusterSecret(hexSecret string) ([]byte, error)
- func EncodeProtectorKey(secretBytes []byte) string
- func GlobalPinInfoSliceToSerial(gpi []api.GlobalPinInfo) []api.GlobalPinInfoSerial
- func NewClusterHost(ctx context.Context, cfg *Config) (host.Host, error)
- func PeersFromMultiaddrs(addrs []ma.Multiaddr) []peer.ID
- func SetFacilityLogLevel(f, l string)
- type API
- type Cluster
- func NewCluster( host host.Host, cfg *Config, consensus Consensus, api API, ipfs IPFSConnector, st state.State, tracker PinTracker, monitor PeerMonitor, allocator PinAllocator, informer Informer, ) (*Cluster, error)
- func (c *Cluster) AddFile(reader *multipart.Reader, params *api.AddParams) (cid.Cid, error)
- func (c *Cluster) ConnectGraph() (api.ConnectGraph, error)
- func (c *Cluster) Done() <-chan struct{}
- func (c *Cluster) ID() api.ID
- func (c *Cluster) Join(addr ma.Multiaddr) error
- func (c *Cluster) PeerAdd(pid peer.ID) (api.ID, error)
- func (c *Cluster) PeerRemove(pid peer.ID) error
- func (c *Cluster) Peers() []api.ID
- func (c *Cluster) Pin(pin api.Pin) error
- func (c *Cluster) PinGet(h cid.Cid) (api.Pin, error)
- func (c *Cluster) Pins() []api.Pin
- func (c *Cluster) Ready() <-chan struct{}
- func (c *Cluster) Recover(h cid.Cid) (api.GlobalPinInfo, error)
- func (c *Cluster) RecoverAllLocal() ([]api.PinInfo, error)
- func (c *Cluster) RecoverLocal(h cid.Cid) (pInfo api.PinInfo, err error)
- func (c *Cluster) Shutdown() error
- func (c *Cluster) StateSync() error
- func (c *Cluster) Status(h cid.Cid) (api.GlobalPinInfo, error)
- func (c *Cluster) StatusAll() ([]api.GlobalPinInfo, error)
- func (c *Cluster) StatusAllLocal() []api.PinInfo
- func (c *Cluster) StatusLocal(h cid.Cid) api.PinInfo
- func (c *Cluster) Sync(h cid.Cid) (api.GlobalPinInfo, error)
- func (c *Cluster) SyncAll() ([]api.GlobalPinInfo, error)
- func (c *Cluster) SyncAllLocal() ([]api.PinInfo, error)
- func (c *Cluster) SyncLocal(h cid.Cid) (pInfo api.PinInfo, err error)
- func (c *Cluster) Unpin(h cid.Cid) error
- func (c *Cluster) Version() string
- type Component
- type Config
- type Consensus
- type IPFSConnector
- type Informer
- type PeerMonitor
- type Peered
- type PinAllocator
- type PinTracker
- type RPCAPI
- func (rpcapi *RPCAPI) BlockAllocate(ctx context.Context, in api.PinSerial, out *[]string) error
- func (rpcapi *RPCAPI) ConnectGraph(ctx context.Context, in struct{}, out *api.ConnectGraphSerial) error
- func (rpcapi *RPCAPI) ConsensusAddPeer(ctx context.Context, in peer.ID, out *struct{}) error
- func (rpcapi *RPCAPI) ConsensusLogPin(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) ConsensusLogUnpin(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) ConsensusPeers(ctx context.Context, in struct{}, out *[]peer.ID) error
- func (rpcapi *RPCAPI) ConsensusRmPeer(ctx context.Context, in peer.ID, out *struct{}) error
- func (rpcapi *RPCAPI) ID(ctx context.Context, in struct{}, out *api.IDSerial) error
- func (rpcapi *RPCAPI) IPFSBlockGet(ctx context.Context, in api.PinSerial, out *[]byte) error
- func (rpcapi *RPCAPI) IPFSBlockPut(ctx context.Context, in api.NodeWithMeta, out *struct{}) error
- func (rpcapi *RPCAPI) IPFSConfigKey(ctx context.Context, in string, out *interface{}) error
- func (rpcapi *RPCAPI) IPFSConnectSwarms(ctx context.Context, in struct{}, out *struct{}) error
- func (rpcapi *RPCAPI) IPFSPin(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) IPFSPinLs(ctx context.Context, in string, out *map[string]api.IPFSPinStatus) error
- func (rpcapi *RPCAPI) IPFSPinLsCid(ctx context.Context, in api.PinSerial, out *api.IPFSPinStatus) error
- func (rpcapi *RPCAPI) IPFSRepoStat(ctx context.Context, in struct{}, out *api.IPFSRepoStat) error
- func (rpcapi *RPCAPI) IPFSSwarmPeers(ctx context.Context, in struct{}, out *api.SwarmPeersSerial) error
- func (rpcapi *RPCAPI) IPFSUnpin(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) Join(ctx context.Context, in api.MultiaddrSerial, out *struct{}) error
- func (rpcapi *RPCAPI) PeerAdd(ctx context.Context, in string, out *api.IDSerial) error
- func (rpcapi *RPCAPI) PeerMonitorLatestMetrics(ctx context.Context, in string, out *[]api.Metric) error
- func (rpcapi *RPCAPI) PeerMonitorLogMetric(ctx context.Context, in api.Metric, out *struct{}) error
- func (rpcapi *RPCAPI) PeerRemove(ctx context.Context, in peer.ID, out *struct{}) error
- func (rpcapi *RPCAPI) Peers(ctx context.Context, in struct{}, out *[]api.IDSerial) error
- func (rpcapi *RPCAPI) Pin(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) PinGet(ctx context.Context, in api.PinSerial, out *api.PinSerial) error
- func (rpcapi *RPCAPI) Pins(ctx context.Context, in struct{}, out *[]api.PinSerial) error
- func (rpcapi *RPCAPI) Recover(ctx context.Context, in api.PinSerial, out *api.GlobalPinInfoSerial) error
- func (rpcapi *RPCAPI) RecoverAllLocal(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
- func (rpcapi *RPCAPI) RecoverLocal(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
- func (rpcapi *RPCAPI) SendInformerMetric(ctx context.Context, in struct{}, out *api.Metric) error
- func (rpcapi *RPCAPI) Status(ctx context.Context, in api.PinSerial, out *api.GlobalPinInfoSerial) error
- func (rpcapi *RPCAPI) StatusAll(ctx context.Context, in struct{}, out *[]api.GlobalPinInfoSerial) error
- func (rpcapi *RPCAPI) StatusAllLocal(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
- func (rpcapi *RPCAPI) StatusLocal(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
- func (rpcapi *RPCAPI) Sync(ctx context.Context, in api.PinSerial, out *api.GlobalPinInfoSerial) error
- func (rpcapi *RPCAPI) SyncAll(ctx context.Context, in struct{}, out *[]api.GlobalPinInfoSerial) error
- func (rpcapi *RPCAPI) SyncAllLocal(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
- func (rpcapi *RPCAPI) SyncLocal(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
- func (rpcapi *RPCAPI) Track(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) TrackerRecover(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
- func (rpcapi *RPCAPI) TrackerRecoverAll(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
- func (rpcapi *RPCAPI) TrackerStatus(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
- func (rpcapi *RPCAPI) TrackerStatusAll(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
- func (rpcapi *RPCAPI) Unpin(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) Untrack(ctx context.Context, in api.PinSerial, out *struct{}) error
- func (rpcapi *RPCAPI) Version(ctx context.Context, in struct{}, out *api.Version) error
包文件
allocate.go cluster.go cluster_config.go clusterhost.go connect_graph.go ipfscluster.go logging.go rpc_api.goutil.go version.go
常量
const ( DefaultConfigCrypto = crypto.RSA DefaultConfigKeyLength = 2048 DefaultListenAddr = "/ip4/0.0.0.0/tcp/9096" DefaultStateSyncInterval = 600 * time.Second DefaultIPFSSyncInterval = 130 * time.Second DefaultMonitorPingInterval = 15 * time.Second DefaultPeerWatchInterval = 5 * time.Second DefaultReplicationFactor = -1 DefaultLeaveOnShutdown = false DefaultDisableRepinning = false DefaultPeerstoreFile = "peerstore" )
配置默认值
变量
var LoggingFacilities = map[string]string{ "cluster": "INFO", "restapi": "INFO", "ipfshttp": "INFO", "monitor": "INFO", "mapstate": "INFO", "consensus": "INFO", "pintracker": "INFO", "ascendalloc": "INFO", "diskinfo": "INFO", "apitypes": "INFO", "config": "INFO", "shardingdags": "INFO", "localdags": "INFO", "adder": "INFO", "optracker": "INFO", }
LoggingFacilities提供了群集使用的日志记录标识符列表及其默认日志记录级别。
var LoggingFacilitiesExtra = map[string]string{ "p2p-gorpc": "CRITICAL", "swarm2": "ERROR", "libp2p-raft": "CRITICAL", "raft": "ERROR", }
LoggingFacilitiesExtra提供ipfs-cluster依赖项中使用的日志记录标识符,这可能对显示有用。连同它们的默认值。
var RPCProtocol = protocol.ID( fmt.Sprintf("/ipfscluster/%d.%d/rpc", Version.Major, Version.Minor), )
RPCProtocol用于在集群对等节点之间发送libp2p消息
ReadyTimeout指定启动期间多久时间后放弃(等待共识准备就绪)可能需要根据共识层中的超时进行调整。
版本是当前的集群版本。组件,apis和工具之间的版本对齐确保了它们之间的兼容性。
func DecodeClusterSecret
DecodeClusterSecret分析十六进制编码的字符串,检查它是否正好是32字节长,并将其值返回为byte-slice.x
func EncodeProtectorKey
EncodeProtectorKey将字节转换为其十六进制字符串表示形式。
func GlobalPinInfoSliceToSerial
func GlobalPinInfoSliceToSerial(gpi []api.GlobalPinInfo) []api.GlobalPinInfoSerial
GlobalPinInfoSliceToSerial是一个辅助函数,用于序列化api.GlobalPinInfos。
func NewClusterHost
NewClusterHost使用提供的集群配置中的选项创建libp2p主机。
func PeersFromMultiaddrs
PeersFromMultiaddrs返回给定地址中的所有不同对等节点。每个对等节点只会在结果中出现一次,即使提供了几个多地址。
func SetFacilityLogLevel
func SetFacilityLogLevel(f, l string)
SetFacilityLogLevel设置给定模块的日志级别
type API
type API interface { Component }
API是为Cluster提供API的组件。这是一个基本组件。
type Cluster
type Cluster struct {
// contains filtered or unexported fields
}
Cluster是主要的IPFS集群组件。它为它提供了go-API并协调组成系统的组件。
func NewCluster
func NewCluster( host host.Host, cfg *Config, consensus Consensus, api API, ipfs IPFSConnector, st state.State, tracker PinTracker, monitor PeerMonitor, allocator PinAllocator, informer Informer, ) (*Cluster, error)
NewCluster构建一个新的IPFS集群对等节点。它初始化LibP2P主机,创建RPC服务器和客户端并设置所有组件。
当此调用返回时,新的集群对等节点可能仍在执行初始化任务(共识可能仍然是自举)。如果需要等到对等端完全启动,请使用Cluster.Ready()。
func (*Cluster) AddFile
AddFile将一个文件添加到集群的ipfs守护进程中。The ipfs importer pipeline用于DAGify文件。根据输入参数,可以将此DAG本地添加到调用集群对等节点的ipfs存储库,或者在整个集群中进行共享。
func (*Cluster) ConnectGraph
func (c *Cluster) ConnectGraph() (api.ConnectGraph, error)
ConnectGraph返回对哪些集群对等节点和ipfs守护进程相互连接的描述
func (*Cluster) Done
func (c *Cluster) Done() <-chan struct{}
Done提供了一种了解节点是否已关闭的方法(例如,因为它已从群集中删除)
func (*Cluster) ID
D返回有关Cluster对等节点的信息
func (*Cluster) Join
Join通过引导到给定的多地址将此对等节点添加到现有集群。它的工作原理是在目标集群上调用PeerAdd,并确保新对等节点已准备好发现并与其他集群联系。
func (*Cluster) PeerAdd
PeerAdd为此集群添加了新的对等节点。
为了使其良好运行,新对等节点应该是可发现的(我们的对等节点的一部分或连接到现有对等节点之一)并且可以访问。由于PeerAdd允许添加未运行或可访问的对等节点,因此建议从新对等节点调用Join()。
新的对等ID将被传递到共识组件以添加到peerset。
func (*Cluster) PeerRemove
PeerRemove从此集群中删除对等节点。
节点将从共识同伴中删除。如果没有禁用,这可能首先触发所有内容的重复。
func (*Cluster) Peers
Peers返回此集群成员的ID。
func (*Cluster) Pin
Pin使群集Pin成为Cid。这意味着将Cid添加到IPFS集群对等共享状态。根据集群固定策略,PinTracker可以请求IPFS守护程序固定Cid。
如果操作无法持久保存到全局状态,则Pin会返回错误。Pin不反映底层IPFS守护程序固定操作的成功或失败。
如果参数的分配非空,则这些对等节点的优先级高于集群中的其他对等节点。如果max repl因子小于指定的peerset的大小,则在分配顺序中从该集合中选择对等节点。如果min repl因子大于此set的大小,则从集群的其余部分按顺序分配剩余的节点。优先分配是值得的。如果任何优先级对等节点不可用,则Pin将仅从集群的其余部分进行分配。
func (*Cluster) PinGet
PinGet返回由Cluster管理的单个Cid的信息。该信息从当前的全局状态获得。返回的api.Pin提供有关为请求的Cid分配的分配的信息,但不指示该项是否已成功固定。为此,使用Status()。如果给定的Cid不是全局状态的一部分,PinGet会返回错误。
func (*Cluster) Pins
Pins返回由Cluster管理的Cid列表,它们是当前全局状态的一部分。这是管理哪些引脚及其分配的真实来源,但不表示该项是否成功固定。为此,请使用StatusAll()。
func (*Cluster) Ready
func (c *Cluster) Ready() <-chan struct{}
Ready返回一个信道,该信道在该对等体完全初始化时发出信号(包括共识)。
func (*Cluster) Recover
Recover会触发所有集群对等节点中给定Cid的恢复操作。
func (*Cluster) RecoverAllLocal
RecoverAllLocal会触发此对等节点跟踪的所有Cid的RecoverLocal操作。
func (*Cluster) RecoverLocal
RecoverLocal仅触发此对等节点中给定Cid的恢复操作。它在恢复后返回更新的PinInfo。
func (*Cluster) Shutdown
Shutdown会停止IPFS集群组件
func (*Cluster) StateSync
StateSync将共识状态与引脚跟踪器同步,确保跟踪共享状态中的每个Cid,并确保引脚跟踪器不跟踪应有的更多CID。
func (*Cluster) Status
Status返回从所有当前对等节点获取的给定Cid的GlobalPinInfo。如果发生错误,GlobalPinInfo应包含可从其他对等方获取的信息。
func (*Cluster) StatusAll
func (c *Cluster) StatusAll() ([]api.GlobalPinInfo, error)
StatusAll返回所有对等节点中所有被跟踪的Cid的GlobalPinInfo。如果发生错误,则将包含可从其他对等节点获取的信息。
func (*Cluster) StatusAllLocal
StatusAllLocal返回此对等节点中所有跟踪的CID的PinInfo。
func (*Cluster) StatusLocal
StatusLocal为给定的Cid返回此对等节点的PinInfo。
func (*Cluster) Sync
Sync会在所有集群对等节点中触发给定Cid的SyncLocal()操作
func (*Cluster) SyncAll
func (c *Cluster) SyncAll() ([]api.GlobalPinInfo, error)
SyncAll在所有集群对等体中触发SyncAllLocal()操作,确保跟踪项的状态与IPFS守护程序报告的状态匹配,并将结果作为GlobalPinInfo返回。如果发生错误,则将包含可从对等体获取的尽可能多的信息。
func (*Cluster) SyncAllLocal
SyncAllLocal确保此对等节点中所有跟踪项的当前状态与IPFS守护程序报告的状态匹配。
SyncAllLocal返回由于操作而更新的PinInfo列表以及处于错误状态的列表。
func (*Cluster) SyncLocal
SyncLocal为给定的Cid执行本地同步操作。这将告诉跟踪器验证Cid对IPFS守护程序的状态。它返回Cid的更新PinInfo。
func (*Cluster) Unpin
Unpin使集群取消固定Cid。这意味着将Cid添加到IPFS集群节点共享状态。
如果操作无法持久保存到全局状态,则Unpin将返回错误。Unpin不反映底层IPFS守护程序取消固定操作的成功或失败。
func (*Cluster) Version
Version返回当前的IPFS集群版本。
type Component
Component代表一部分ipfscluster。群集组件通常运行自己的goroutine(例如http服务器)。它们使用rpc.Client实例与主Cluster组件和其他组件(本地和远程)进行通信。
type Config
type Config struct { config.Saver // Libp2p ID and private key for Cluster communication (including) // the Consensus component. ID peer.ID PrivateKey crypto.PrivKey // User-defined peername for use as human-readable identifier. Peername string // Cluster secret for private network. Peers will be in the same cluster if and // only if they have the same ClusterSecret. The cluster secret must be exactly // 64 characters and contain only hexadecimal characters (`[0-9a-f]`). Secret []byte // Leave Cluster on shutdown. Politely informs other peers // of the departure and removes itself from the consensus // peer set. The Cluster size will be reduced by one. LeaveOnShutdown bool // Listen parameters for the Cluster libp2p Host. Used by // the RPC and Consensus components. ListenAddr ma.Multiaddr // Time between syncs of the consensus state to the // tracker state. Normally states are synced anyway, but this helps // when new nodes are joining the cluster. Reduce for faster // consistency, increase with larger states. StateSyncInterval time.Duration // Number of seconds between syncs of the local state and // the state of the ipfs daemon. This ensures that cluster // provides the right status for tracked items (for example // to detect that a pin has been removed. Reduce for faster // consistency, increase when the number of pinned items is very // large. IPFSSyncInterval time.Duration // ReplicationFactorMax indicates the target number of nodes // that should pin content. For exampe, a replication_factor of // 3 will have cluster allocate each pinned hash to 3 peers if // possible. // See also ReplicationFactorMin. A ReplicationFactorMax of -1 // will allocate to every available node. ReplicationFactorMax int // ReplicationFactorMin indicates the minimum number of healthy // nodes pinning content. If the number of nodes available to pin // is less than this threshold, an error will be returned. // In the case of peer health issues, content pinned will be // re-allocated if the threshold is crossed. // For exampe, a ReplicationFactorMin of 2 will allocate at least // two peer to hold content, and return an error if this is not // possible. ReplicationFactorMin int // MonitorPingInterval is the frequency with which a cluster peer pings // the monitoring component. The ping metric has a TTL set to the double // of this value. MonitorPingInterval time.Duration // PeerWatchInterval is the frequency that we use to watch for changes // in the consensus peerset and save new peers to the configuration // file. This also affects how soon we realize that we have // been removed from a cluster. PeerWatchInterval time.Duration // If true, DisableRepinning, ensures that no repinning happens // when a node goes down. // This is useful when doing certain types of maintainance, or simply // when not wanting to rely on the monitoring system which needs a revamp. DisableRepinning bool // Peerstore file specifies the file on which we persist the // libp2p host peerstore addresses. This file is regularly saved. PeerstoreFile string // contains filtered or unexported fields }
Config是包含可自定义变量的配置对象,用于初始化主ipfs-cluster组件。它实现了config.ComponentConfig接口。
func (*Config) ConfigKey
ConfigKey返回一个人类可读的字符串来标识集群Config。
func (*Config) Default
Default使用默认工作值填充所有Config字段。这意味着,它将生成一个有效的随机ID,PrivateKey和Secret。
func (*Config) GetPeerstorePath
GetPeerstorePath返回PeerstoreFile的完整路径,通过将该值与配置的BaseDir连接获得(如果已设置)。未设置BaseDir时返回空字符串。
func (*Config) LoadJSON
LoadJSON接收原始json格式的配置并从中设置Config字段。请注意,它应该是由ToJSON()生成的JSON。
func (*Config) ToJSON
ToJSON生成一个人性化的Config版本。
func (*Config) Validate
Validate将检查此配置的值似乎是有效的。
type Consensus
type Consensus interface { Component // Returns a channel to signal that the consensus layer is ready // allowing the main component to wait for it during start. Ready() <-chan struct{} // Logs a pin operation LogPin(c api.Pin) error // Logs an unpin operation LogUnpin(c api.Pin) error AddPeer(p peer.ID) error RmPeer(p peer.ID) error State() (state.State, error) // Provide a node which is responsible to perform // specific tasks which must only run in 1 cluster peer Leader() (peer.ID, error) // Only returns when the consensus state has all log // updates applied to it WaitForSync() error // Clean removes all consensus data Clean() error // Peers returns the peerset participating in the Consensus Peers() ([]peer.ID, error) }
Consensus是一个在IPFS集群中保持共享状态并触发对该状态更新的操作的组件。目前,共识需要能够选择/提供集群领导者,并且集群主要组件的实施非常紧迫。
type IPFSConnector
type IPFSConnector interface { Component ID() (api.IPFSID, error) Pin(context.Context, cid.Cid, int) error Unpin(context.Context, cid.Cid) error PinLsCid(context.Context, cid.Cid) (api.IPFSPinStatus, error) PinLs(ctx context.Context, typeFilter string) (map[string]api.IPFSPinStatus, error) // ConnectSwarms make sure this peer's IPFS daemon is connected to // other peers IPFS daemons. ConnectSwarms() error // SwarmPeers returns the IPFS daemon's swarm peers SwarmPeers() (api.SwarmPeers, error) // ConfigKey returns the value for a configuration key. // Subobjects are reached with keypaths as "Parent/Child/GrandChild...". ConfigKey(keypath string) (interface{}, error) // RepoStat returns the current repository size and max limit as // provided by "repo stat". RepoStat() (api.IPFSRepoStat, error) // BlockPut directly adds a block of data to the IPFS repo BlockPut(api.NodeWithMeta) error // BlockGet retrieves the raw data of an IPFS block BlockGet(cid.Cid) ([]byte, error) }
IPFSConnector是一个允许集群与IPFS守护程序交互的组件,是一个基本组件。
type Informer
Informer提供来自对等节点的度量信息。然后,由线人产生的指标传递给PinAllocator,PinAllocator将使用它们来确定内容的固定位置。该指标与Cluster的其余部分无关。
type PeerMonitor
type PeerMonitor interface { Component // LogMetric stores a metric. It can be used to manually inject // a metric to a monitor. LogMetric(api.Metric) error // PublishMetric sends a metric to the rest of the peers. // How to send it, and to who, is to be decided by the implementation. PublishMetric(api.Metric) error // LatestMetrics returns a map with the latest metrics of matching name // for the current cluster peers. LatestMetrics(name string) []api.Metric // Alerts delivers alerts generated when this peer monitor detects // a problem (i.e. metrics not arriving as expected). Alerts can be used // to trigger self-healing measures or re-pinnings of content. Alerts() <-chan api.Alert }
PeerMonitor是负责发布对等节点指标和从集群中其他对等节点读取指标的组件。PinAllocator将使用监视器提供的指标作为Pin分配的候选条件。
PeerMonitor组件还提供警报通道,当不再接收度量标准并且监视器将其识别为问题时,该通道将发出信号。
type Peered
Peered表示需要了解群集中的对等节点以及节点集的任何更改的组件。
type PinAllocator
type PinAllocator interface { Component // Allocate returns the list of peers that should be assigned to // Pin content in order of preference (from the most preferred to the // least). The "current" map contains valid metrics for peers // which are currently pinning the content. The candidates map // contains the metrics for all peers which are eligible for pinning // the content. Allocate(c cid.Cid, current, candidates, priority map[peer.ID]api.Metric) ([]peer.ID, error) }
PinAllocator决定将特定内容固定在何处。为了做出这样的决定,它接收pin参数,当前有分配内容的对等体和可用于可以分配内容的所有对等体的度量。
type PinTracker
type PinTracker interface { Component // Track tells the tracker that a Cid is now under its supervision // The tracker may decide to perform an IPFS pin. Track(api.Pin) error // Untrack tells the tracker that a Cid is to be forgotten. The tracker // may perform an IPFS unpin operation. Untrack(cid.Cid) error // StatusAll returns the list of pins with their local status. StatusAll() []api.PinInfo // Status returns the local status of a given Cid. Status(cid.Cid) api.PinInfo // SyncAll makes sure that all tracked Cids reflect the real IPFS status. // It returns the list of pins which were updated by the call. SyncAll() ([]api.PinInfo, error) // Sync makes sure that the Cid status reflect the real IPFS status. // It returns the local status of the Cid. Sync(cid.Cid) (api.PinInfo, error) // RecoverAll calls Recover() for all pins tracked. RecoverAll() ([]api.PinInfo, error) // Recover retriggers a Pin/Unpin operation in a Cids with error status. Recover(cid.Cid) (api.PinInfo, error) }
PinTracker表示跟踪此集群中引脚状态的组件,并确保它们与IPFS守护程序同步。该组件应该是线程安全的。
type RPCAPI
type RPCAPI struct {
// contains filtered or unexported fields
}
RPCAPI是一种go-libp2p-gorpc服务,它提供内部ipfs-cluster API,使组件和集群对等节点能够相互通信和请求操作。
RPC API方法通常重定向到ipfs-cluster的不同组件中的实际方法,几乎没有添加逻辑。有关其行为的详细信息,请参阅有关这些方法的文档。
func (*RPCAPI) BlockAllocate
BlockAllocate返回块的分配。这在加法器中使用。当ReplicationFactor <0时,它与引脚分配不同。
func (*RPCAPI) ConnectGraph
func (rpcapi *RPCAPI) ConnectGraph(ctx context.Context, in struct{}, out *api.ConnectGraphSerial) error
ConnectGraph运行Cluster.GetConnectGraph()。
func (*RPCAPI) ConsensusAddPeer
ConsensusAddPeer运行Consensus.AddPeer().
func (*RPCAPI) ConsensusLogPin
ConsensusLogPin运行Consensus.LogPin().
func (*RPCAPI) ConsensusLogUnpin
ConsensusLogUnpin运行Consensus.LogUnpin().
func (*RPCAPI) ConsensusPeers
ConsensusPeers运行Consensus.Peers().
func (*RPCAPI) ConsensusRmPeer
ConsensusRmPeer运行Consensus.RmPeer().
func (*RPCAPI) ID
ID运行Cluster.ID()
func (*RPCAPI) IPFSBlockGet
IPFSBlockGet运行IPFSConnector.BlockGet().
func (*RPCAPI) IPFSBlockPut
IPFSBlockPut运行IPFSConnector.BlockPut().
func (*RPCAPI) IPFSConfigKey
IPFSConfigKey运行IPFSConnector.ConfigKey().
func (*RPCAPI) IPFSConnectSwarms
IPFSConnectSwarms运行IPFSConnector.ConnectSwarms().
func (*RPCAPI) IPFSPin
IPFSPin运行IPFSConnector.Pin().
func (*RPCAPI) IPFSPinLs
func (rpcapi *RPCAPI) IPFSPinLs(ctx context.Context, in string, out *map[string]api.IPFSPinStatus) error
IPFSPinLs运行IPFSConnector.PinLs().
func (*RPCAPI) IPFSPinLsCid
func (rpcapi *RPCAPI) IPFSPinLsCid(ctx context.Context, in api.PinSerial, out *api.IPFSPinStatus) error
IPFSPinLsCid运行IPFSConnector.PinLsCid().
func (*RPCAPI) IPFSRepoStat
IPFSRepoStat运行IPFSConnector.RepoStat().
func (*RPCAPI) IPFSSwarmPeers
func (rpcapi *RPCAPI) IPFSSwarmPeers(ctx context.Context, in struct{}, out *api.SwarmPeersSerial) error
IPFSSwarmPeers运行IPFSConnector.SwarmPeers().
func (*RPCAPI) IPFSUnpin
IPFSUnpin运行IPFSConnector.Unpin().
func (*RPCAPI) Join
Join运行Cluster.Join().
func (*RPCAPI) PeerAdd
PeerAdd运行Cluster.PeerAdd().
func (*RPCAPI) PeerMonitorLatestMetrics
func (rpcapi *RPCAPI) PeerMonitorLatestMetrics(ctx context.Context, in string, out *[]api.Metric) error
PeerMonitorLatestMetrics运行PeerMonitor.LatestMetrics().
func (*RPCAPI) PeerMonitorLogMetric
PeerMonitorLogMetric运行PeerMonitor.LogMetric().
func (*RPCAPI) PeerRemove
PeerRemove运行Cluster.PeerRm().
func (*RPCAPI) Peers
Peers运行Cluster.Peers().
func (*RPCAPI) Pin
Pin运行Cluster.Pin().
func (*RPCAPI) PinGet
PinGet运行Cluster.PinGet().
func (*RPCAPI) Pins
Pins运行Cluster.Pins().
func (*RPCAPI) Recover
func (rpcapi *RPCAPI) Recover(ctx context.Context, in api.PinSerial, out *api.GlobalPinInfoSerial) error
Recover运行Cluster.Recover().
func (*RPCAPI) RecoverAllLocal
func (rpcapi *RPCAPI) RecoverAllLocal(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
RecoverAllLocal运行Cluster.RecoverAllLocal().
func (*RPCAPI) RecoverLocal
func (rpcapi *RPCAPI) RecoverLocal(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
RecoverLocal运行Cluster.RecoverLocal().
func (*RPCAPI) SendInformerMetric
SendInformerMetric运行Cluster.sendInformerMetric().
func (*RPCAPI) Status
func (rpcapi *RPCAPI) Status(ctx context.Context, in api.PinSerial, out *api.GlobalPinInfoSerial) error
Status运行Cluster.Status().
func (*RPCAPI) StatusAll
func (rpcapi *RPCAPI) StatusAll(ctx context.Context, in struct{}, out *[]api.GlobalPinInfoSerial) error
StatusAll运行Cluster.StatusAll().
func (*RPCAPI) StatusAllLocal
func (rpcapi *RPCAPI) StatusAllLocal(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
StatusAllLocal运行Cluster.StatusAllLocal().
func (*RPCAPI) StatusLocal
func (rpcapi *RPCAPI) StatusLocal(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
StatusLocal运行Cluster.StatusLocal().
func (*RPCAPI) Sync
func (rpcapi *RPCAPI) Sync(ctx context.Context, in api.PinSerial, out *api.GlobalPinInfoSerial) error
Sync运行Cluster.Sync().
func (*RPCAPI) SyncAll
func (rpcapi *RPCAPI) SyncAll(ctx context.Context, in struct{}, out *[]api.GlobalPinInfoSerial) error
SyncAll运行Cluster.SyncAll().
func (*RPCAPI) SyncAllLocal
func (rpcapi *RPCAPI) SyncAllLocal(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
SyncAllLocal运行Cluster.SyncAllLocal().
func (*RPCAPI) SyncLocal
func (rpcapi *RPCAPI) SyncLocal(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
SyncLocal运行Cluster.SyncLocal().
func (*RPCAPI) Track
Track运行PinTracker.Track().
func (*RPCAPI) TrackerRecover
func (rpcapi *RPCAPI) TrackerRecover(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
TrackerRecover运行PinTracker.Recover().
func (*RPCAPI) TrackerRecoverAll
func (rpcapi *RPCAPI) TrackerRecoverAll(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
TrackerRecoverAll运行PinTracker.RecoverAll().f
func (*RPCAPI) TrackerStatus
func (rpcapi *RPCAPI) TrackerStatus(ctx context.Context, in api.PinSerial, out *api.PinInfoSerial) error
TrackerStatus运行PinTracker.Status().
func (*RPCAPI) TrackerStatusAll
func (rpcapi *RPCAPI) TrackerStatusAll(ctx context.Context, in struct{}, out *[]api.PinInfoSerial) error
TrackerStatusAll运行PinTracker.StatusAll().
func (*RPCAPI) Unpin
Unpin运行Cluster.Unpin().
func (*RPCAPI) Untrack
Untrack运行PinTracker.Untrack().
func (*RPCAPI) Version
Version运行Cluster.Version().
目录
Path | Synopsis |
---|---|
adder | adder实现了向集群管理的IPFS守护进程添加内容的功能。 |
adder/adderutils | adderutils提供了一些用于向集群添加内容的实用程序。 |
adder/ipfsadd | ipfsadd是go-ipfs / core / coreunix / add.go的简化副本 |
adder/local | local实现了一个ClusterDAGService,它在固定之前将内容分块并添加到本地对等节点 |
adder/sharding | sharding实现分片ClusterDAGService在添加时将内容放置在不同的分片中,创建最终的Cluster DAG并固定它。 |
allocator/ascendalloc | ascendalloc实现了一个ipfscluster.PinAllocator,它根据按升序排序指标返回分配。 |
allocator/descendalloc | descendalloc实现ipfscluster.PinAllocator,根据按降序排序度量标准返回分配。 |
allocator/util | util是分配器实现使用的实用程序包。 |
api | api包含ipfs-cluster API中使用的类型的声明,以使它们可以在不同的工具中重用。 |
api/rest | rest实现了IPFS Cluster API组件。. |
api/rest/client | client为“api / rest”组件提供的IPFS Cluster API提供Go Client。 |
config | config为不同的Cluster组件提供接口和实用程序,以注册,读取,写入和验证存储在中央配置文件中的配置节。 |
consensus/raft | raft为IPFS集群实现了一个使用Raft(go-libp2p-raft)的Consensus组件。 |
informer/disk | disk实现了ipfs-cluster informer,它可以作为api.Metric从IPFS守护程序提供与磁盘相关的不同指标。 |
informer/numpin | numpin实现了一个ipfs-cluster informer,它确定了这个节点固定的项目数,并将其作为api.Metric返回 |
ipfs-cluster-ctl | ipfs-cluster-ctl应用程序。 |
ipfsconn/ipfshttp | ipfshttp实现了IPFS群集IPFSConnector组件。 |
monitor/basic | basic为IPFS Cluster实现了一个基本的PeerMonitor组件。 |
monitor/metrics | metrics提供了使用指标的常用功能,特别适用于监控组件。 |
monitor/pubsubmon | pubsubmon为IPFS集群实现PeerMonitor组件,该组件使用PubSub发送和接收度量。 |
pintracker/maptracker | maptracker为IPFS集群实现了PinTracker组件。 |
pintracker/optracker | optracker实现了功能,以跟踪pintracker组件实现所需的引脚和操作的状态。 |
pintracker/stateless | |
pintracker/util | |
pstoremgr | pstoremgr提供了一个Manager,可以简化从libp2p主机处理集群对等多地址的添加,列出和删除的过程。 |
rpcutil | rpcutil提供了执行go-libp2p-gorpc调用的实用程序方法,尤其是gorpc.MultiCall()。 |
state | state保存IPFS集群的任何状态实现必须满足的接口。 |
state/mapstate | mapstate通过使用映射来跟踪共享共享状态来实现IPFS集群的State接口。 |
test | test为测试实用程序提供了类似于mocks的ipfs-cluster |