configuration

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

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
	RPC     string
	// IsAdmin indicates status of api (internal or external)
	IsAdmin bool
}

APIRunner holds configuration for api

func NewAPIRunner added in v0.2.0

func NewAPIRunner(admin bool) APIRunner

NewAPIRunner creates new api config

func (*APIRunner) String added in v0.2.0

func (ar *APIRunner) String() string

type AvailabilityChecker added in v0.9.8

type AvailabilityChecker struct {
	Enabled        bool
	KeeperURL      string
	RequestTimeout uint
	CheckPeriod    uint
}

AvailabilityChecker holds configuration for checking is network available for process API calls

func NewAvailabilityChecker added in v0.9.8

func NewAvailabilityChecker() AvailabilityChecker

type Backup added in v0.9.0

type Backup struct {
	// Enabled switches on backuping
	Enabled bool

	// TmpDirectory is directory for tmp storage of backup data. Must be created
	TmpDirectory string

	// TargetDirectory is directory where backups will be moved to
	TargetDirectory string

	// MetaInfoFile contains meta info about current incremental backup. It will be in json format
	MetaInfoFile string

	// ConfirmFile: we wait this file being created when backup was saved on remote host
	ConfirmFile string

	// BackupFile is file with incremental backup data
	BackupFile string

	// DirNameTemplate is template for saving current incremental backup. Should be like "pulse-%d"
	DirNameTemplate string

	// BackupWaitPeriod - how much time we will wait for appearing of file ConfirmFile
	BackupWaitPeriod uint

	// LastBackupInfoFile contains info about last backup. Must exist and lie inside Storage.DataDirectory
	// Is's a full path.
	LastBackupInfoFile string

	// PostProcessBackupCmd - command which will be invoked after creating backup. It might be used to
	// send backup to remote node and do some external checks. If everything is ok, this command must create ConfirmFile
	// It will be invoked with environment variable 'INSOLAR_CURRENT_BACKUP_DIR'
	// PostProcessBackupCmd[0] is interpreted as command, and PostProcessBackupCmd[1:] as arguments
	PostProcessBackupCmd []string
}

Backup holds configuration for backuping.

type BuiltIn

type BuiltIn struct{}

BuiltIn configuration, no options at the moment

type Bus added in v0.9.0

type Bus struct {
	ReplyTimeout time.Duration
}

Bus holds some timeout options

func NewBus added in v0.9.0

func NewBus() Bus

type Configuration

type Configuration struct {
	Host                HostNetwork
	Service             ServiceNetwork
	Ledger              Ledger
	Log                 Log
	Metrics             Metrics
	LogicRunner         LogicRunner
	APIRunner           APIRunner
	AdminAPIRunner      APIRunner
	AvailabilityChecker AvailabilityChecker
	KeysPath            string
	CertificatePath     string
	Tracer              Tracer
	Introspection       Introspection
	Exporter            Exporter
	Bus                 Bus
}

Configuration contains configuration params for all Insolar components

func NewConfiguration

func NewConfiguration() Configuration

NewConfiguration creates new default configuration

type Exporter added in v0.7.5

type Exporter struct {
	// Addr specifies address where exporter server starts
	Addr string
	// DurationBetweenRequests specifies time limit between requests to exporter
	DurationBetweenRequests time.Duration
}

Exporter holds exporter configuration. Is was assumed, that exporter will be used for exporting data for observer Exporter is grpc-base service

func NewExporter added in v0.9.0

func NewExporter() Exporter

NewExporter creates new default configuration for export.

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

func NewHolderWithFilePaths(files ...string) *Holder

NewHolderWithFilePaths creates new holder with possible configuration files paths.

func (*Holder) Init added in v0.3.0

func (h *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 (h *Holder) Load() error

Load method reads configuration from default file path

func (*Holder) LoadFromFile

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

LoadFromFile method reads configuration from particular file path

func (*Holder) MustInit added in v0.3.0

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

MustInit wrapper around Init function which panics on error.

func (*Holder) Save

func (h *Holder) Save() error

Save method writes configuration to default file path

func (*Holder) SaveAs

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

SaveAs method writes configuration to particular file path

type HostNetwork

type HostNetwork struct {
	Transport           Transport
	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 Introspection added in v0.9.0

type Introspection struct {
	// Addr specifies address where introspection server starts
	Addr string
}

Introspection holds introspection configuration.

func NewIntrospection added in v0.9.0

func NewIntrospection() Introspection

NewIntrospection creates new default configuration for introspection.

type JaegerConfig added in v0.6.2

type JaegerConfig struct {
	CollectorEndpoint string
	AgentEndpoint     string
	ProbabilityRate   float64
}

JaegerConfig holds Jaeger settings.

type JetSplit added in v0.9.0

type JetSplit struct {
	// RecordsCountThreshold is a drop threshold in records to perform split for jet.
	ThresholdRecordsCount int
	// ThresholdOverflowCount is a how many times in row ThresholdRecordsCount should be surpassed.
	ThresholdOverflowCount int
	// DepthLimit limits jet tree depth (maximum possible jets = 2^DepthLimit)
	DepthLimit uint8
}

JetSplit holds configuration for jet split.

type Ledger

type Ledger struct {
	// Storage defines storage configuration.
	Storage Storage
	// JetSplit holds jet split configuration.
	JetSplit JetSplit

	// 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

	// Backup holds configuration of BackupMaker
	Backup Backup

	// CleanerDelay holds value of pulses, that should happen before end of LightChainLimit and start
	// of LME's data cleaning
	CleanerDelay int

	// MaxNotificationsPerPulse holds the limit for abandoned requests notifications limit
	MaxNotificationsPerPulse uint

	// FilamentCacheLimit holds the limit for cache items for an object
	FilamentCacheLimit 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 {
	// Default level for logger
	Level string
	//// Default level for global filtering
	//GlobalLevel string
	// Logging adapter - only zerolog by now
	Adapter string
	// Log output format - e.g. json or text
	Formatter string
	// Log output type - e.g. stderr, syslog
	OutputType string
	// Write-parallel limit for the output
	OutputParallelLimit string
	// Parameter for output - depends on OutputType
	OutputParams string

	// Number of regular log events that can be buffered, =0 to disable
	BufferSize int
	// Number of low-latency log events that can be buffered, =-1 to disable, =0 - default size
	LLBufferSize int
}

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 {
	PulseTime int32 // ms

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

type PulsarConfiguration struct {
	Log      Log
	Pulsar   Pulsar
	Tracer   Tracer
	KeysPath string
	Metrics  Metrics
}

PulsarConfiguration contains configuration params for the pulsar node

func NewPulsarConfiguration added in v0.9.1

func NewPulsarConfiguration() PulsarConfiguration

NewPulsarConfiguration creates new default configuration for pulsar

type PulsarNodeAddress added in v0.3.0

type PulsarNodeAddress struct {
	Address   string
	PublicKey string
}

type PulseDistributor added in v0.7.5

type PulseDistributor struct {
	BootstrapHosts      []string
	PulseRequestTimeout int32 // ms
}

type ServiceNetwork

type ServiceNetwork struct {
	CacheDirectory string
}

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
	// BadgerValueLogGCDiscardRatio controls badger's value log GC behaviour.
	// Compaction on value log file happens only if data would be compacted to at least 1-BadgerValueLogGCDiscardRatio ratio.
	BadgerValueLogGCDiscardRatio float64
}

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 not empty - this should be public address of instance (to connect from the "other" side to)
	FixedPublicAddress string
}

Transport holds transport protocol configuration for HostNetwork

Jump to

Keyboard shortcuts

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