cmdutils

package
v0.11.0-rc10 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: Apache-2.0, MIT Imports: 27 Imported by: 0

Documentation

Overview

Package cmdutils contains utilities to facilitate building of command line applications launching cluster peers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

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
	Maptracker       *maptracker.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)
	Clean() error
}

StateManager is the interface that allows to import, export and clean different cluster states depending on the consensus component used.

func NewStateManager

func NewStateManager(consensus string, ident *config.Identity, cfgs *Configs) (StateManager, error)

NewStateManager returns an state manager implementation for the given consensus ("raft" or "crdt"). It will need initialized configs.

Jump to

Keyboard shortcuts

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