configuration

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 196

README

Insolar – Configuration

GoDoc

Package provides configuration params for all Insolar components and helper for config resources management.

Configuration

Configuration struct is a root registry for all components config. It provides constructor method NewConfiguration() which creates new instance of configuration object filled with default values.

Each root level Insolar component has a constructor with config as argument. Each components should have its own config struct with the same name in this package. Each config struct should have constructor which returns instance with default params.

Holder

Package also provides Holder to easily manage config resources. It based on Viper config solution for Golang and helps to Marshal\Unmarshal config structs, manage files, ENV and command line variables.

Holder provides functionality to merge configuration from different sources.

Merge priority
  1. command line flags
  2. ENV variables
  3. yaml file
  4. Default config
Manage configuration from cli

Insolar cli tool helps user to manage configuration.

insolar config --help

Documentation

Overview

Package configuration holds configuration for all components in Insolar host binary It allows also helps to manage config resources using Holder

Usage:

package main

import (
	"github.com/insolar/insolar/configuration"
	"fmt"
)

func main() {
	holder := configuration.NewHolder()
	fmt.Printf("Default configuration:\n %+v\n", holder.Configuration)
	holder.SaveAs("insolar.yml")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToString

func ToString(in interface{}) string

ToString converts any configuration struct to yaml string

Types

type APIRunner added in v0.2.0

type APIRunner struct {
	Address string
	Call    string
	RPC     string
	Timeout uint32
}

APIRunner holds configuration for api

func NewAPIRunner added in v0.2.0

func NewAPIRunner() APIRunner

NewAPIRunner creates new api config

func (*APIRunner) String added in v0.2.0

func (ar *APIRunner) String() string

type Backoff added in v0.7.5

type Backoff struct {
	Factor float64
	// Jitter eases contention by randomizing backoff steps
	Jitter bool
	// Min and Max are the minimum and maximum values of the counter
	Min, Max time.Duration
}

Backoff configures retry backoff algorithm

type BuiltIn

type BuiltIn struct{}

BuiltIn configuration, no options at the moment

type Configuration

type Configuration struct {
	Host            HostNetwork
	Service         ServiceNetwork
	Ledger          Ledger
	Log             Log
	Metrics         Metrics
	LogicRunner     LogicRunner
	APIRunner       APIRunner
	Pulsar          Pulsar
	VersionManager  VersionManager
	KeysPath        string
	CertificatePath string
	Tracer          Tracer
}

Configuration contains configuration params for all Insolar components

func NewConfiguration

func NewConfiguration() Configuration

NewConfiguration creates new default configuration

type ConnectionType added in v0.3.0

type ConnectionType string
const (
	TCP ConnectionType = "tcp"
)

func (ConnectionType) String added in v0.3.0

func (ct ConnectionType) String() string

type Exporter added in v0.7.5

type Exporter struct {
	// ExportLag is lag in second before we start to export pulse
	ExportLag uint32
}

Exporter holds configuration of Exporter

type GoPlugin added in v0.0.6

type GoPlugin struct {
	// RunnerListen - address Go plugins executor listens to
	RunnerListen string
	// RunnerProtocol - protocol (network) of above address,
	// e.g. "tcp", "unix"... see `net.Dial`
	RunnerProtocol string
}

GoPlugin configuration

type Holder

type Holder struct {
	Configuration Configuration
	// contains filtered or unexported fields
}

Holder provides methods to manage configuration

func NewHolder

func NewHolder() *Holder

NewHolder creates new Holder with default configuration

func (*Holder) Init added in v0.3.0

func (c *Holder) Init(required bool) (*Holder, error)

Init init all configuration data from config file and environment.

Does not fail on not found config file if the 'required' flag set to false.

func (*Holder) Load

func (c *Holder) Load() error

Load method reads configuration from default file path

func (*Holder) LoadEnv added in v0.0.6

func (c *Holder) LoadEnv() error

LoadEnv overrides configuration with env variables

func (*Holder) LoadFromFile

func (c *Holder) LoadFromFile(path string) error

LoadFromFile method reads configuration from particular file path

func (*Holder) MustInit added in v0.3.0

func (c *Holder) MustInit(required bool) *Holder

MustInit wrapper around Init function which panics on error.

func (*Holder) Save

func (c *Holder) Save() error

Save method writes configuration to default file path

func (*Holder) SaveAs

func (c *Holder) SaveAs(path string) error

SaveAs method writes configuration to particular file path

type HostNetwork

type HostNetwork struct {
	Transport           Transport
	IsRelay             bool  // set if node must be relay explicit
	InfinityBootstrap   bool  // set true for infinity tries to bootstrap
	MinTimeout          int   // bootstrap timeout min
	MaxTimeout          int   // bootstrap timeout max
	TimeoutMult         int   // bootstrap timout multiplier
	SignMessages        bool  // signing a messages if true
	HandshakeSessionTTL int32 // ms
}

HostNetwork holds configuration for HostNetwork

func NewHostNetwork

func NewHostNetwork() HostNetwork

NewHostNetwork creates new default HostNetwork configuration

type JaegerConfig added in v0.6.2

type JaegerConfig struct {
	CollectorEndpoint string
	AgentEndpoint     string
	ProbabilityRate   float64
}

JaegerConfig holds Jaeger settings.

type Ledger

type Ledger struct {
	// Storage defines storage configuration.
	Storage Storage
	// PulseManager holds configuration for PulseManager.
	PulseManager PulseManager
	// RecentStorage holds configuration for RecentStorage
	RecentStorage RecentStorage

	// LightChainLimit is maximum pulse difference (NOT number of pulses)
	// between current and the latest replicated on heavy.
	//
	// IMPORTANT: It should be the same on ALL nodes.
	LightChainLimit int

	// JetSizesHistoryDepth holds maximum number of drop sizes
	JetSizesHistoryDepth int

	// Exporter holds configuration of Exporter
	Exporter Exporter

	// PendingRequestsLimit holds a number of pending requests, what can be stored in the system
	// before they are declined
	PendingRequestsLimit int
}

Ledger holds configuration for ledger.

func NewLedger added in v0.0.6

func NewLedger() Ledger

NewLedger creates new default Ledger configuration.

type Log

type Log struct {
	Level     string
	Adapter   string
	Formatter string
}

Log holds configuration for logging

func NewLog

func NewLog() Log

NewLog creates new default configuration for logging

type LogicRunner

type LogicRunner struct {
	// RPCListen - address logic runner binds RPC API to
	RPCListen string
	// RPCProtoco - protocol (network) of above address,
	// e.g. "tcp", "unix"... see `net.Dial`
	RPCProtocol string
	// BuiltIn - configuration of builtin executor
	BuiltIn *BuiltIn
	// GoPlugin - configuration of executor based on Go plugins
	GoPlugin *GoPlugin
}

LogicRunner configuration

func NewLogicRunner

func NewLogicRunner() LogicRunner

NewLogicRunner - returns default config of the logic runner

type Metrics added in v0.2.0

type Metrics struct {
	ListenAddress string
	Namespace     string
	ZpagesEnabled bool
	// ReportingPeriod defines exporter reporting period
	// if zero, exporter uses default value (1s)
	ReportingPeriod time.Duration
}

Metrics holds configuration for metrics publishing.

func NewMetrics added in v0.2.0

func NewMetrics() Metrics

NewMetrics creates new default configuration for metrics publishing.

type Pulsar added in v0.0.6

type Pulsar struct {
	ConnectionType      ConnectionType
	MainListenerAddress string
	Storage             Storage

	PulseTime                      int32 // ms
	ReceivingSignTimeout           int32 // ms
	ReceivingNumberTimeout         int32 // ms
	ReceivingVectorTimeout         int32 // ms
	ReceivingSignsForChosenTimeout int32 // ms

	Neighbours []PulsarNodeAddress

	NumberDelta uint32

	DistributionTransport Transport
	PulseDistributor      PulseDistributor
}

Pulsar holds configuration for pulsar node.

func NewPulsar added in v0.0.6

func NewPulsar() Pulsar

NewPulsar creates new default configuration for pulsar node.

type PulsarNodeAddress added in v0.3.0

type PulsarNodeAddress struct {
	Address        string
	ConnectionType ConnectionType
	PublicKey      string
}

type PulseDistributor added in v0.7.5

type PulseDistributor struct {
	BootstrapHosts            []string
	PingRequestTimeout        int32 // ms
	RandomHostsRequestTimeout int32 // ms
	PulseRequestTimeout       int32 // ms
	RandomNodesCount          int
}

type PulseManager added in v0.6.3

type PulseManager struct {
	// HeavySyncEnabled enables replication to heavy (could be disabled for testing purposes)
	HeavySyncEnabled bool
	// HeavySyncMessageLimit soft limit of single message for replication to heavy.
	HeavySyncMessageLimit int
	// Backoff configures retry backoff algorithm for Heavy Sync
	HeavyBackoff Backoff
	// SplitThreshold is a drop size threshold in bytes to perform split.
	SplitThreshold uint64
}

PulseManager holds configuration for PulseManager.

type RecentStorage added in v0.7.5

type RecentStorage struct {
	// Default TTL is a value of default ttl for redirects
	DefaultTTL int
}

RecentStorage holds configuration for RecentStorage

type ServiceNetwork

type ServiceNetwork struct {
	Skip int // magic number that indicates what delta after last ignored pulse we should wait
}

ServiceNetwork is configuration for ServiceNetwork.

func NewServiceNetwork

func NewServiceNetwork() ServiceNetwork

NewServiceNetwork creates a new ServiceNetwork configuration.

type Storage added in v0.2.0

type Storage struct {
	// DataDirectory is a directory where database's files live.
	DataDirectory string
	// TxRetriesOnConflict defines how many retries on transaction conflicts
	// storage update methods should do.
	TxRetriesOnConflict int
}

Storage configures Ledger's storage.

type Tracer added in v0.6.2

type Tracer struct {
	Jaeger JaegerConfig
	// TODO: add SamplingRules configuration
	SamplingRules struct{}
}

Tracer configures tracer.

func NewTracer added in v0.6.2

func NewTracer() Tracer

NewTracer creates new default Tracer configuration.

type Transport

type Transport struct {
	// protocol type
	Protocol string
	// Address to listen
	Address string
	// if true transport will use network traversal technique(like STUN) to get PublicAddress
	BehindNAT bool
	// if not empty - this should be public address of instance (to connect from the "other" side to)
	// conflicts in BehindNAT
	FixedPublicAddress string
}

Transport holds transport protocol configuration for HostNetwork

type VersionManager added in v0.6.3

type VersionManager struct {
	MinAlowedVersion string
}

VersionManager holds configuration for VersionManager publishing.

func NewVersionManager added in v0.6.3

func NewVersionManager() VersionManager

NewVersionManager creates new default configuration for VersionManager publishing.

Jump to

Keyboard shortcuts

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