Documentation
¶
Index ¶
- Constants
- Variables
- func Filename(configRoot string) (string, error)
- func Marshal(value any) ([]byte, error)
- func Path(configRoot, configFile string) (string, error)
- func PathRoot() (string, error)
- type AdminServer
- type Bootstrap
- type Config
- type Datastore
- type DelegatedRouting
- type DirectAnnounce
- type Duration
- type HttpPublisher
- type Identity
- type Ingest
- type Policy
- type ProviderServer
- type PublisherKind
Constants ¶
const ( // DefaultPathName is the default config dir name. DefaultPathName = ".index-provider" // DefaultPathRoot is the path to the default config dir location. DefaultPathRoot = "~/" + DefaultPathName // DefaultConfigFile is the filename of the configuration file. DefaultConfigFile = "config" // EnvDir is the environment variable used to change the path root. EnvDir = "PROVIDER_PATH" )
const (
PrivateKeyPathEnvVar = "INDEXPROVIDER_PRIV_KEY_PATH"
)
Variables ¶
var ( ErrInitialized = errors.New("configuration file already exists") ErrNotInitialized = errors.New("not initialized") )
var ErrInvalidPeerAddr = errors.New("invalid peer address")
ErrInvalidPeerAddr signals an address is not a valid peer address.
Functions ¶
func Filename ¶
Filename returns the configuration file path given a configuration root directory. If the configuration root directory is empty, use the default.
Types ¶
type AdminServer ¶
type AdminServer struct {
// Admin is the admin API listen address
ListenMultiaddr string
ReadTimeout Duration
WriteTimeout Duration
}
func NewAdminServer ¶
func NewAdminServer() AdminServer
NewAdminServer instantiates a new AdminServer config with default values.
func (*AdminServer) ListenNetAddr ¶
func (as *AdminServer) ListenNetAddr() (string, error)
func (*AdminServer) PopulateDefaults ¶
func (c *AdminServer) PopulateDefaults()
PopulateDefaults replaces zero-values in the config with default values.
type Bootstrap ¶
type Bootstrap struct {
// Peers is the local nodes's bootstrap peer addresses
Peers []string
// MinimumPeers governs whether to bootstrap more connections. If the node
// has less open connections than this number, it will open connections to
// the bootstrap nodes. Set to 0 to disable bootstrapping.
MinimumPeers int
}
func NewBootstrap ¶
func NewBootstrap() Bootstrap
NewBootstrap instantiates a new Bootstrap config with default values.
type Config ¶
type Config struct {
Identity Identity
Datastore Datastore
Ingest Ingest
ProviderServer ProviderServer
AdminServer AdminServer
Bootstrap Bootstrap
DirectAnnounce DirectAnnounce
DelegatedRouting DelegatedRouting
}
Config is used to load config files.
func InitWithIdentity ¶
func (*Config) PopulateDefaults ¶
func (c *Config) PopulateDefaults()
type Datastore ¶
type Datastore struct {
// Type is the type of datastore
Type string
// Dir is the directory within the config root where the datastore is kept
Dir string
}
Datastore tracks the configuration of the datastore.
func NewDatastore ¶
func NewDatastore() Datastore
NewDatastore instantiates a new Datastore config with default values.
func (*Datastore) PopulateDefaults ¶
func (c *Datastore) PopulateDefaults()
PopulateDefaults replaces zero-values in the config with default values.
type DelegatedRouting ¶ added in v0.13.0
type DelegatedRouting struct {
ListenMultiaddr string
ReadTimeout Duration
WriteTimeout Duration
// CidTtl is a lifetime of a cid after which it is considered expired
CidTtl Duration
// AdFlushFrequency defines a frequency of a flush operation that is going to be performed on the current chunk. In other words a non empty
// current chunk will be converted to an advertisement and published if it's older than this value. Set to 0 to disable.
AdFlushFrequency Duration
// ChunkSize is size of a chunk before it gets advertised to an indexer.
// In other words it's a number of CIDs per advertisement
ChunkSize int
// SnapshotSize is the maximum number of records in the Provide payload after which it is considered a snapshot.
// Snapshots don't have individual timestamps recorded into the datastore. Instead, timestamps are recorded as a binary blob after processing is done.
SnapshotSize int
// ProviderID is a Peer ID of the IPFS node that the delegated routing server is expecting advertisements from
ProviderID string
// DsPageSize is a size of the database page that is going to be used on delegated routing server initialisation.
DsPageSize int
// Addrs is a list of multiaddresses of the IPFS node that the delegated routing server is expecting advertisements from
Addrs []string
}
DelegatedRouting tracks the configuration of delegated routing server. If specified, index provider will expose a delegated routing server that will allow an IPFS node to advertise their CIDs through the delegated routing protocol.
func NewDelegatedRouting ¶ added in v0.13.0
func NewDelegatedRouting() DelegatedRouting
NewDelegatedRouting instantiates a new delegated routing config with default values.
func (*DelegatedRouting) ListenNetAddr ¶ added in v0.13.0
func (as *DelegatedRouting) ListenNetAddr() (string, error)
func (*DelegatedRouting) PopulateDefaults ¶ added in v0.13.0
func (c *DelegatedRouting) PopulateDefaults()
PopulateDefaults replaces zero-values in the config with default values.
type DirectAnnounce ¶
type DirectAnnounce struct {
// NoPubsubAnnounce disables pubsub announce when set to true. The default
// behavior (false) is to enable sending advertisement announcements via
// gossib pubsub.
NoPubsubAnnounce bool
// URLs is a list of indexer URLs to send HTTP announce messages to.
URLs []string
}
DirectAnnounce configures the target indexers that advertisement announce messages are sent directly to via HTTP.
func NewDirectAnnounce ¶
func NewDirectAnnounce() DirectAnnounce
NewDirectAnnounce returns DirectAnnounce with values set to their defaults.
type Duration ¶
Duration wraps time.Duration to provide json serialization and deserialization.
NOTE: the zero value encodes to an empty string.
func (Duration) MarshalText ¶
func (*Duration) UnmarshalText ¶
type HttpPublisher ¶
type HttpPublisher struct {
// AnnounceMultiaddr is the address supplied in the announce message
// telling indexers the address to use to retrieve advertisements. This
// configures the addresses to announce when using a Libp2pPublisher,
// HttpPublisher, or Libp2pHttpPublisher.
//
// If not specified, the ListenMultiaddr is used with HttpPubliser, the
// libp2p host address is used with Libp2pPublisher and both are used with
// Libp2pHttpPublisher.
AnnounceMultiaddr string
// ListenMultiaddr is the address of the interface to listen for HTTP
// requests for advertisements. Set this to "" to disable serving plain
// HTTP if only libp2phttp is wanted.
ListenMultiaddr string
}
func NewHttpPublisher ¶
func NewHttpPublisher() HttpPublisher
NewHttpPublisher instantiates a new config with default values.
func (*HttpPublisher) ListenNetAddr ¶
func (hs *HttpPublisher) ListenNetAddr() (string, error)
type Identity ¶
Identity tracks the configuration of the local node's identity.
func CreateIdentity ¶
CreateIdentity initializes a new identity.
func (Identity) DecodeOrCreate ¶
func (Identity) DecodeOrCreatePrivateKey ¶
func (identity Identity) DecodeOrCreatePrivateKey(out io.Writer, passphrase string) (ic.PrivKey, error)
DecodeOrCreatePrivateKey is a helper to decode the user's PrivateKey. If the key hasn't been provided in json config then it's going to be read from PrivateKeyPathEnvVar. If that file doesn't exist then a new key is going to be generated and saved there.
type Ingest ¶
type Ingest struct {
// LinkCacheSize is the maximum number of links that cash can store before
// LRU eviction. If a single linked list has more links than the cache can
// hold, the cache is resized to be able to hold all links.
LinkCacheSize int
// LinkedChunkSize is the number of multihashes in each chunk of in the
// advertised entries linked list. If multihashes are 128 bytes, then
// setting LinkedChunkSize = 16384 will result in blocks of about 2Mb when
// full.
LinkedChunkSize int
// PubSubTopic used to advertise ingestion announcements.
PubSubTopic string
// PurgeLinkCache tells whether to purge the link cache on daemon startup.
PurgeLinkCache bool
// HttpPublisher configures the dagsync ipnisync publisher.
HttpPublisher HttpPublisher
// PublisherKind specifies which dagsync.Publisher implementation to use.
// When set to "http", the publisher serves plain HTTP. When set to
// "libp2p" the publisher serves HTTP over libp2p. When set to
// "libp2phttp", the publisher serves both plain HTTP and HTTP over libp2p.
//
// Plain HTTP is disabled if HttpPublisher.ListenMultiaddr is set to "".
PublisherKind PublisherKind
// SyncPolicy configures which indexers are allowed to sync advertisements
// with this provider over a data transfer session.
SyncPolicy Policy
}
Ingest configures settings related to the ingestion protocol.
func NewIngest ¶
func NewIngest() Ingest
NewIngest instantiates a new Ingest configuration with default values.
func (*Ingest) PopulateDefaults ¶
func (c *Ingest) PopulateDefaults()
PopulateDefaults replaces zero-values in the config with default values.
type Policy ¶
type Policy struct {
// Allow is either false or true, and determines whether a peer is allowed
// (true) or is blocked (false), by default.
Allow bool
// Except is a list of peer IDs that are exceptions to the Allow policy.
// If Allow is true, then all peers are allowed except those listed in
// Except. If Allow is false, then no peers are allowed except those listed
// in Except. in other words, Allow=true means that Except is a deny-list
// and Allow=false means that Except is an allow-list.
Except []string
}
Policy configures which indexer peers are allowed and which are blocked.
type ProviderServer ¶
type ProviderServer struct {
// ListenMultiaddr is the multiaddr string for the node's listen address
ListenMultiaddr string
// RetrievalMultiaddrs are the addresses to advertise for data retrieval.
// Defaults to the provider's libp2p host listen addresses.
RetrievalMultiaddrs []string
}
func NewProviderServer ¶
func NewProviderServer() ProviderServer
NewProviderServer instantiates a new ProviderServer config with default values.
func (*ProviderServer) PopulateDefaults ¶
func (c *ProviderServer) PopulateDefaults()
PopulateDefaults replaces zero-values in the config with default values.
type PublisherKind ¶
type PublisherKind string
const ( HttpPublisherKind PublisherKind = "http" Libp2pPublisherKind PublisherKind = "libp2p" Libp2pHttpPublisherKind PublisherKind = "libp2phttp" )