Documentation
¶
Index ¶
- type AddResponse
- type Client
- func (c *Client) Add(ctx context.Context, reader io.Reader, name string) (*AddResponse, error)
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) Get(ctx context.Context, cid string, ipfsAPIURL string) (io.ReadCloser, error)
- func (c *Client) GetPeerCount(ctx context.Context) (int, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) Pin(ctx context.Context, cid string, name string, replicationFactor int) (*PinResponse, error)
- func (c *Client) PinStatus(ctx context.Context, cid string) (*PinStatus, error)
- func (c *Client) Unpin(ctx context.Context, cid string) error
- type ClusterConfigManager
- func (cm *ClusterConfigManager) DiscoverClusterPeersFromGateway() ([]ClusterPeerInfo, error)
- func (cm *ClusterConfigManager) DiscoverClusterPeersFromLibP2P(h host.Host) error
- func (cm *ClusterConfigManager) EnsureConfig() error
- func (cm *ClusterConfigManager) FixIPFSConfigAddresses() error
- func (cm *ClusterConfigManager) RepairPeerConfiguration() error
- func (cm *ClusterConfigManager) UpdateAllClusterPeers() error
- func (cm *ClusterConfigManager) UpdatePeerAddresses(addrs []string) error
- type ClusterPeerInfo
- type ClusterServiceConfig
- type Config
- type IPFSClient
- type PinResponse
- type PinStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddResponse ¶
type AddResponse struct {
Name string `json:"name"`
Cid string `json:"cid"`
Size int64 `json:"size"`
}
AddResponse represents the response from adding content to IPFS
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an IPFS Cluster HTTP API client for storage operations
func (*Client) Get ¶
Get retrieves content from IPFS by CID Note: This uses the IPFS HTTP API (typically on port 5001), not the Cluster API
func (*Client) GetPeerCount ¶
GetPeerCount returns the number of cluster peers
func (*Client) Pin ¶
func (c *Client) Pin(ctx context.Context, cid string, name string, replicationFactor int) (*PinResponse, error)
Pin pins a CID with specified replication factor IPFS Cluster expects pin options (including name) as query parameters, not in JSON body
type ClusterConfigManager ¶
type ClusterConfigManager struct {
// contains filtered or unexported fields
}
ClusterConfigManager manages IPFS Cluster configuration files
func NewClusterConfigManager ¶
NewClusterConfigManager creates a new IPFS Cluster config manager
func (*ClusterConfigManager) DiscoverClusterPeersFromGateway ¶ added in v0.72.0
func (cm *ClusterConfigManager) DiscoverClusterPeersFromGateway() ([]ClusterPeerInfo, error)
DiscoverClusterPeersFromGateway queries the central gateway for registered IPFS Cluster peers
func (*ClusterConfigManager) DiscoverClusterPeersFromLibP2P ¶
func (cm *ClusterConfigManager) DiscoverClusterPeersFromLibP2P(h host.Host) error
DiscoverClusterPeersFromLibP2P uses libp2p host to find other cluster peers
func (*ClusterConfigManager) EnsureConfig ¶
func (cm *ClusterConfigManager) EnsureConfig() error
EnsureConfig ensures the IPFS Cluster service.json exists and is properly configured
func (*ClusterConfigManager) FixIPFSConfigAddresses ¶
func (cm *ClusterConfigManager) FixIPFSConfigAddresses() error
FixIPFSConfigAddresses fixes localhost addresses in IPFS config
func (*ClusterConfigManager) RepairPeerConfiguration ¶ added in v0.72.0
func (cm *ClusterConfigManager) RepairPeerConfiguration() error
RepairPeerConfiguration attempts to fix configuration issues and re-synchronize peers
func (*ClusterConfigManager) UpdateAllClusterPeers ¶
func (cm *ClusterConfigManager) UpdateAllClusterPeers() error
UpdateAllClusterPeers discovers all cluster peers from the gateway and updates local config
func (*ClusterConfigManager) UpdatePeerAddresses ¶ added in v0.72.0
func (cm *ClusterConfigManager) UpdatePeerAddresses(addrs []string) error
UpdatePeerAddresses updates the peer_addresses in service.json with given multiaddresses
type ClusterPeerInfo ¶ added in v0.90.0
type ClusterPeerInfo struct {
ID string `json:"id"`
Multiaddress string `json:"multiaddress"`
NodeName string `json:"node_name"`
LastSeen time.Time `json:"last_seen"`
}
ClusterPeerInfo represents information about an IPFS Cluster peer
type ClusterServiceConfig ¶
type ClusterServiceConfig struct {
Cluster struct {
Peername string `json:"peername"`
Secret string `json:"secret"`
ListenMultiaddress []string `json:"listen_multiaddress"`
PeerAddresses []string `json:"peer_addresses"`
LeaveOnShutdown bool `json:"leave_on_shutdown"`
} `json:"cluster"`
Consensus struct {
CRDT struct {
ClusterName string `json:"cluster_name"`
TrustedPeers []string `json:"trusted_peers"`
Batching struct {
MaxBatchSize int `json:"max_batch_size"`
MaxBatchAge string `json:"max_batch_age"`
} `json:"batching"`
RepairInterval string `json:"repair_interval"`
} `json:"crdt"`
} `json:"consensus"`
API struct {
RestAPI struct {
HTTPListenMultiaddress string `json:"http_listen_multiaddress"`
} `json:"restapi"`
IPFSProxy struct {
ListenMultiaddress string `json:"listen_multiaddress"`
NodeMultiaddress string `json:"node_multiaddress"`
} `json:"ipfsproxy"`
PinSvcAPI struct {
HTTPListenMultiaddress string `json:"http_listen_multiaddress"`
} `json:"pinsvcapi"`
} `json:"api"`
IPFSConnector struct {
IPFSHTTP struct {
NodeMultiaddress string `json:"node_multiaddress"`
} `json:"ipfshttp"`
} `json:"ipfs_connector"`
Raw map[string]interface{} `json:"-"`
}
ClusterServiceConfig represents the service.json configuration
type Config ¶
type Config struct {
// ClusterAPIURL is the base URL for IPFS Cluster HTTP API (e.g., "http://localhost:9094")
// If empty, defaults to "http://localhost:9094"
ClusterAPIURL string
// Timeout is the timeout for client operations
// If zero, defaults to 60 seconds
Timeout time.Duration
}
Config holds configuration for the IPFS client
type IPFSClient ¶
type IPFSClient interface {
Add(ctx context.Context, reader io.Reader, name string) (*AddResponse, error)
Pin(ctx context.Context, cid string, name string, replicationFactor int) (*PinResponse, error)
PinStatus(ctx context.Context, cid string) (*PinStatus, error)
Get(ctx context.Context, cid string, ipfsAPIURL string) (io.ReadCloser, error)
Unpin(ctx context.Context, cid string) error
Health(ctx context.Context) error
GetPeerCount(ctx context.Context) (int, error)
Close(ctx context.Context) error
}
IPFSClient defines the interface for IPFS operations
type PinResponse ¶
PinResponse represents the response from pinning a CID
type PinStatus ¶
type PinStatus struct {
Cid string `json:"cid"`
Name string `json:"name"`
Status string `json:"status"` // "pinned", "pinning", "queued", "unpinned", "error"
ReplicationMin int `json:"replication_min"`
ReplicationMax int `json:"replication_max"`
ReplicationFactor int `json:"replication_factor"`
Peers []string `json:"peers"`
Error string `json:"error,omitempty"`
}
PinStatus represents the status of a pinned CID