Documentation ¶
Overview ¶
Package ipfshttp implements an IPFS Cluster IPFSConnector component. It uses the IPFS HTTP API to communicate to IPFS.
Index ¶
- Constants
- Variables
- type Config
- type Connector
- func (ipfs *Connector) BlockGet(ctx context.Context, c api.Cid) ([]byte, error)
- func (ipfs *Connector) BlockStream(ctx context.Context, blocks <-chan api.NodeWithMeta) error
- func (ipfs *Connector) ConfigKey(keypath string) (interface{}, error)
- func (ipfs *Connector) ConnectSwarms(ctx context.Context) error
- func (ipfs *Connector) ID(ctx context.Context) (api.IPFSID, error)
- func (ipfs *Connector) Pin(ctx context.Context, pin api.Pin) error
- func (ipfs *Connector) PinLs(ctx context.Context, typeFilters []string, out chan<- api.IPFSPinInfo) error
- func (ipfs *Connector) PinLsCid(ctx context.Context, pin api.Pin) (api.IPFSPinStatus, error)
- func (ipfs *Connector) RepoGC(ctx context.Context) (api.RepoGC, error)
- func (ipfs *Connector) RepoStat(ctx context.Context) (api.IPFSRepoStat, error)
- func (ipfs *Connector) Resolve(ctx context.Context, path string) (api.Cid, error)
- func (ipfs *Connector) SetClient(c *rpc.Client)
- func (ipfs *Connector) Shutdown(ctx context.Context) error
- func (ipfs *Connector) SwarmPeers(ctx context.Context) ([]peer.ID, error)
- func (ipfs *Connector) Unpin(ctx context.Context, hash api.Cid) error
Constants ¶
const ( DefaultNodeAddr = "/ip4/127.0.0.1/tcp/5001" DefaultConnectSwarmsDelay = 30 * time.Second DefaultIPFSRequestTimeout = 5 * time.Minute DefaultPinTimeout = 2 * time.Minute DefaultUnpinTimeout = 3 * time.Hour DefaultRepoGCTimeout = 24 * time.Hour DefaultInformerTriggerInterval = 0 // disabled DefaultUnpinDisable = false )
Default values for Config.
Variables ¶
var DNSTimeout = 5 * time.Second
DNSTimeout is used when resolving DNS multiaddresses in this module
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config struct { config.Saver // Host/Port for the IPFS daemon. NodeAddr ma.Multiaddr // ConnectSwarmsDelay specifies how long to wait after startup before // attempting to open connections from this peer's IPFS daemon to the // IPFS daemons of other peers. ConnectSwarmsDelay time.Duration // IPFS Daemon HTTP Client POST timeout IPFSRequestTimeout time.Duration // Pin Operation timeout PinTimeout time.Duration // Unpin Operation timeout UnpinTimeout time.Duration // RepoGC Operation timeout RepoGCTimeout time.Duration // How many pin and block/put operations need to happen before we do a // special broadcast informer metrics to the network. 0 to disable. InformerTriggerInterval int // Disables the unpin operation and returns an error. UnpinDisable bool // Tracing flag used to skip tracing specific paths when not enabled. Tracing bool }
Config is used to initialize a Connector and allows to customize its behavior. It implements the config.ComponentConfig interface.
func (*Config) ApplyEnvVars ¶ added in v0.10.0
ApplyEnvVars fills in any Config fields found as environment variables.
func (*Config) ConfigKey ¶ added in v0.2.0
ConfigKey provides a human-friendly identifier for this type of Config.
func (*Config) Default ¶ added in v0.2.0
Default sets the fields of this Config to sensible default values.
func (*Config) LoadJSON ¶ added in v0.2.0
LoadJSON parses a JSON representation of this Config as generated by ToJSON.
func (*Config) ToDisplayJSON ¶ added in v1.0.2
ToDisplayJSON returns JSON config as a string.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector implements the IPFSConnector interface and provides a component which is used to perform on-demand requests against the configured IPFS daemom (such as a pin request).
func NewConnector ¶
NewConnector creates the component and leaves it ready to be started
func (*Connector) BlockStream ¶ added in v1.0.2
BlockStream performs a multipart request to block/put with the blocks received on the channel.
func (*Connector) ConfigKey ¶
ConfigKey fetches the IPFS daemon configuration and retrieves the value for a given configuration key. For example, "Datastore/StorageMax" will return the value for StorageMax in the Datastore configuration object.
func (*Connector) ConnectSwarms ¶
ConnectSwarms requests the ipfs addresses of other peers and triggers ipfs swarm connect requests
func (*Connector) ID ¶
ID performs an ID request against the configured IPFS daemon. It returns the fetched information. If the request fails, or the parsing fails, it returns an error.
func (*Connector) PinLs ¶
func (ipfs *Connector) PinLs(ctx context.Context, typeFilters []string, out chan<- api.IPFSPinInfo) error
PinLs performs a "pin ls --type typeFilter" request against the configured IPFS daemon and sends the results on the given channel. Returns when done.
func (*Connector) PinLsCid ¶
PinLsCid performs a "pin ls <hash>" request. It will use "type=recursive" or "type=direct" (or other) depending on the given pin's MaxDepth setting. It returns an api.IPFSPinStatus for that hash.
func (*Connector) RepoGC ¶ added in v1.0.2
RepoGC performs a garbage collection sweep on the cluster peer's IPFS repo.
func (*Connector) RepoStat ¶ added in v0.5.0
RepoStat returns the DiskUsage and StorageMax repo/stat values from the ipfs daemon, in bytes, wrapped as an IPFSRepoStat object.
func (*Connector) Resolve ¶ added in v0.10.0
Resolve accepts ipfs or ipns path and resolves it into a cid
func (*Connector) Shutdown ¶
Shutdown stops any listeners and stops the component from taking any requests.
func (*Connector) SwarmPeers ¶ added in v0.3.3
SwarmPeers returns the peers currently connected to this ipfs daemon.