config

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2022 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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"
)

Variables

View Source
var (
	ErrInitialized    = errors.New("configuration file already exists")
	ErrNotInitialized = errors.New("not initialized")
)
View Source
var ErrInvalidPeerAddr = errors.New("invalid peer address")

ErrInvalidPeerAddr signals an address is not a valid peer address.

Functions

func Filename

func Filename(configRoot string) (string, error)

Filename returns the configuration file path given a configuration root directory. If the configuration root directory is empty, use the default.

func Marshal

func Marshal(value interface{}) ([]byte, error)

Marshal configuration with JSON.

func Path

func Path(configRoot, configFile string) (string, error)

Path returns the config file path relative to the configuration root. If an empty string is provided for `configRoot`, the default root is used. If configFile is an absolute path, then configRoot is ignored.

func PathRoot

func PathRoot() (string, error)

PathRoot returns the default configuration root directory.

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 added in v0.2.1

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.

func (Bootstrap) PeerAddrs

func (b Bootstrap) PeerAddrs() ([]peer.AddrInfo, error)

PeerAddrs returns the bootstrap peers as a list of AddrInfo.

func (*Bootstrap) SetPeers

func (b *Bootstrap) SetPeers(addrs []peer.AddrInfo)

SetPeers sers the bootstrap peers from a list of AddrInfo.

type Config

type Config struct {
	Identity       Identity
	Datastore      Datastore
	Ingest         Ingest
	ProviderServer ProviderServer
	AdminServer    AdminServer
	Bootstrap      Bootstrap
}

Config is used to load config files.

func Init

func Init(out io.Writer) (*Config, error)

func InitWithIdentity

func InitWithIdentity(identity Identity) (*Config, error)

func Load

func Load(filePath string) (*Config, error)

Load reads the json-serialized config at the specified path.

func (*Config) PopulateDefaults added in v0.2.1

func (c *Config) PopulateDefaults()

func (*Config) Save

func (c *Config) Save(filePath string) error

Save writes the json-serialized config to the specified path.

func (*Config) String

func (c *Config) String() string

String returns a pretty-printed json config.

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 added in v0.2.1

func (c *Datastore) PopulateDefaults()

PopulateDefaults replaces zero-values in the config with default values.

type Duration

type Duration time.Duration

Duration wraps time.Duration to provide json serialization and deserialization.

NOTE: the zero value encodes to an empty string.

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type HttpPublisher added in v0.2.2

type HttpPublisher struct {
	ListenMultiaddr string
}

func NewHttpPublisher added in v0.2.2

func NewHttpPublisher() HttpPublisher

NewHttpPublisher instantiates a new config with default values.

func (*HttpPublisher) ListenNetAddr added in v0.2.2

func (hs *HttpPublisher) ListenNetAddr() (string, error)

type Identity

type Identity struct {
	PeerID  string
	PrivKey string `json:",omitempty"`
}

Identity tracks the configuration of the local node's identity.

func CreateIdentity

func CreateIdentity(out io.Writer) (Identity, error)

CreateIdentity initializes a new identity.

func (Identity) Decode

func (i Identity) Decode() (peer.ID, ic.PrivKey, error)

func (Identity) DecodePrivateKey

func (i Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error)

DecodePrivateKey is a helper to decode the user's PrivateKey.

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 go-legs httpsync publisher.
	HttpPublisher HttpPublisher

	// PublisherKind specifies which legs.Publisher implementation to use.
	PublisherKind PublisherKind
}

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 added in v0.2.1

func (c *Ingest) PopulateDefaults()

PopulateDefaults replaces zero-values in the config with default values.

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 added in v0.2.1

func (c *ProviderServer) PopulateDefaults()

PopulateDefaults replaces zero-values in the config with default values.

type PublisherKind added in v0.2.2

type PublisherKind string
const (
	DTSyncPublisherKind PublisherKind = "dtsync"
	HttpPublisherKind   PublisherKind = "http"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL