Documentation ¶
Overview ¶
Package cmdutils contains utilities to facilitate building of command line applications launching cluster peers.
Index ¶
- func ErrorOut(m string, a ...interface{})
- func HandleSignals(ctx context.Context, cancel context.CancelFunc, cluster *ipfscluster.Cluster, ...) error
- func RandomizePorts(addrs []ma.Multiaddr) ([]ma.Multiaddr, error)
- func WaitForIPFS(ctx context.Context) error
- type ConfigHelper
- func (ch *ConfigHelper) Configs() *Configs
- func (ch *ConfigHelper) GetConsensus() string
- func (ch *ConfigHelper) Identity() *config.Identity
- func (ch *ConfigHelper) LoadConfigFromDisk() error
- func (ch *ConfigHelper) LoadFromDisk() error
- func (ch *ConfigHelper) LoadIdentityFromDisk() error
- func (ch *ConfigHelper) MakeConfigFolder() error
- func (ch *ConfigHelper) Manager() *config.Manager
- func (ch *ConfigHelper) SaveConfigToDisk() error
- func (ch *ConfigHelper) SaveIdentityToDisk() error
- func (ch *ConfigHelper) SetupTracing(forceEnabled bool)
- type Configs
- type StateManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorOut ¶
func ErrorOut(m string, a ...interface{})
ErrorOut formats something and prints it to sdterr.
func HandleSignals ¶
func HandleSignals( ctx context.Context, cancel context.CancelFunc, cluster *ipfscluster.Cluster, host host.Host, dht *dual.DHT, store datastore.Datastore, ) error
HandleSignals orderly shuts down an IPFS Cluster peer on SIGINT, SIGTERM, SIGHUP. It forces command termination on the 3rd-signal count.
func RandomizePorts ¶
RandomizePorts replaces TCP and UDP ports with random, but valid port values, on the given multiaddresses
func WaitForIPFS ¶
WaitForIPFS hangs until IPFS API becomes available or the given context is cancelled. The IPFS API location is determined by the default ipfshttp component configuration and can be overridden using environment variables that affect that configuration. Note that we have to do this in the blind, since we want to wait for IPFS before we even fetch the IPFS component configuration (because the configuration might be hosted on IPFS itself)
Types ¶
type ConfigHelper ¶
type ConfigHelper struct {
// contains filtered or unexported fields
}
ConfigHelper helps managing the configuration and identity files with the standard set of cluster components.
func NewConfigHelper ¶
func NewConfigHelper(configPath, identityPath, consensus string) *ConfigHelper
NewConfigHelper creates a config helper given the paths to the configuration and identity files. Remember to Shutdown() the ConfigHelper.Manager() after use.
func NewLoadedConfigHelper ¶
func NewLoadedConfigHelper(configPath, identityPath string) (*ConfigHelper, error)
NewLoadedConfigHelper creates a config helper given the paths to the configuration and identity files and loads the configurations from disk. Remember to Shutdown() the ConfigHelper.Manager() after use.
func (*ConfigHelper) Configs ¶
func (ch *ConfigHelper) Configs() *Configs
Configs returns the Configs object which holds all the cluster configurations. Configurations are empty if they have not been loaded from disk.
func (*ConfigHelper) GetConsensus ¶
func (ch *ConfigHelper) GetConsensus() string
GetConsensus attempts to return the configured consensus. If the ConfigHelper was initialized with a consensus string then it returns that.
Otherwise it checks whether one of the consensus configurations has been loaded. If both or non have been loaded, it returns an empty string.
func (*ConfigHelper) Identity ¶
func (ch *ConfigHelper) Identity() *config.Identity
Identity returns the Identity object. It returns an empty identity if not loaded yet.
func (*ConfigHelper) LoadConfigFromDisk ¶
func (ch *ConfigHelper) LoadConfigFromDisk() error
LoadConfigFromDisk parses the configuration from disk.
func (*ConfigHelper) LoadFromDisk ¶
func (ch *ConfigHelper) LoadFromDisk() error
LoadFromDisk loads both configuration and identity from disk.
func (*ConfigHelper) LoadIdentityFromDisk ¶
func (ch *ConfigHelper) LoadIdentityFromDisk() error
LoadIdentityFromDisk parses the identity from disk.
func (*ConfigHelper) MakeConfigFolder ¶
func (ch *ConfigHelper) MakeConfigFolder() error
MakeConfigFolder creates the folder to hold configuration and identity files.
func (*ConfigHelper) Manager ¶
func (ch *ConfigHelper) Manager() *config.Manager
Manager returns the config manager with all the cluster configurations registered.
func (*ConfigHelper) SaveConfigToDisk ¶
func (ch *ConfigHelper) SaveConfigToDisk() error
SaveConfigToDisk saves the configuration file to disk.
func (*ConfigHelper) SaveIdentityToDisk ¶
func (ch *ConfigHelper) SaveIdentityToDisk() error
SaveIdentityToDisk saves the identity file to disk.
func (*ConfigHelper) SetupTracing ¶
func (ch *ConfigHelper) SetupTracing(forceEnabled bool)
SetupTracing propagates tracingCfg.EnableTracing to all other configurations. Use only when identity has been loaded or generated. The forceEnabled parameter allows to override the EnableTracing value.
type Configs ¶
type Configs struct { Cluster *ipfscluster.Config Restapi *rest.Config Ipfsproxy *ipfsproxy.Config Ipfshttp *ipfshttp.Config Raft *raft.Config Crdt *crdt.Config Statelesstracker *stateless.Config Pubsubmon *pubsubmon.Config Diskinf *disk.Config Numpininf *numpin.Config Metrics *observations.MetricsConfig Tracing *observations.TracingConfig Badger *badger.Config }
Configs carries config types used by a Cluster Peer.
type StateManager ¶
type StateManager interface { ImportState(io.Reader) error ExportState(io.Writer) error GetStore() (ds.Datastore, error) GetOfflineState(ds.Datastore) (state.State, error) Clean() error }
StateManager is the interface that allows to import, export and clean different cluster states depending on the consensus component used.
func NewStateManager ¶
NewStateManager returns an state manager implementation for the given consensus ("raft" or "crdt"). It will need initialized configs.
func NewStateManagerWithHelper ¶
func NewStateManagerWithHelper(cfgHelper *ConfigHelper) (StateManager, error)
NewStateManagerWithHelper returns a state manager initialized using the configuration and identity provided by the given config helper.