configuration

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 4 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 insconfig package and helps to Marshal\Unmarshal config structs, manage files, ENV and command line variables.

Holder provides functionality to merge configuration from different sources.

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/assured-ledger/ledger-core/configuration"
	"fmt"
)

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

Index

Constants

View Source
const InsolarEnvPrefix = "insolar"

Variables

This section is empty.

Functions

func ToString

func ToString(in interface{}) string

ToString converts any configuration struct to yaml string

Types

type APIRunner

type APIRunner struct {
	Address string
	RPC     string
	// IsAdmin indicates status of api (internal or external)
	IsAdmin     bool
	SwaggerPath string
}

APIRunner holds configuration for api

func NewAPIRunner

func NewAPIRunner(admin bool) APIRunner

NewAPIRunner creates new api config

func (*APIRunner) String

func (ar *APIRunner) String() string

type AvailabilityChecker

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

func NewAvailabilityChecker() AvailabilityChecker

type BaseCloudConfig

type BaseCloudConfig struct {
	Log                 Log
	PulsarConfiguration PulsarConfiguration
	NodeConfigPaths     []string
}

type CommonAppConfig

type CommonAppConfig struct {
	CommonConfig
}

type CommonConfig

type CommonConfig struct {
	Log           Log
	Metrics       Metrics
	Tracer        Tracer
	Introspection Introspection
	KeysPath      string
}

общий конфиг для Net и App в режиме full-node --single-process запускается один инстанс компонентов проблема идентичности CommonConfig в режиме full-node --independent. Решили дублировать эту секцию для Net и App, в режиме --single-process берется CommonConfig из секции Network

type Configuration

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

Configuration contains configuration params for all Insolar components

func NewConfiguration

func NewConfiguration() Configuration

NewConfiguration creates new default configuration

type GoPlugin

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 HeavyNodeConfig

type HeavyNodeConfig struct {
	CommonAppConfig
	LogicRunner LogicRunner
}

type Holder

type Holder struct {
	Configuration *Configuration
	Params        insconfig.Params
}

Holder provides methods to manage configuration

func NewHolder

func NewHolder(path string) *Holder

NewHolder creates new Holder with default configuration

func (*Holder) Load

func (h *Holder) Load() error

Load method reads configuration from params file path

func (*Holder) MustLoad

func (h *Holder) MustLoad() *Holder

MustLoad wrapper around Load method with panics on error

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
	PulseWatchdogTimeout int32 // seconds
}

HostNetwork holds configuration for HostNetwork

func NewHostNetwork

func NewHostNetwork() HostNetwork

NewHostNetwork creates new default HostNetwork configuration

type Introspection

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

Introspection holds introspection configuration.

func NewIntrospection

func NewIntrospection() Introspection

NewIntrospection creates new default configuration for introspection.

type JaegerConfig

type JaegerConfig struct {
	CollectorEndpoint string
	AgentEndpoint     string
	ProbabilityRate   float64
}

JaegerConfig holds Jaeger settings.

type Ledger

type Ledger struct {
	// 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.
	// deprecated
	LightChainLimit int
}

Ledger holds configuration for ledger.

func NewLedger

func NewLedger() Ledger

NewLedger creates new default Ledger configuration.

type LightNodeConfig

type LightNodeConfig struct {
	CommonAppConfig
	LogicRunner LogicRunner
}

type Log

type Log struct {
	// Default level for logger
	Level string

	// Logging adapter - zerolog (json, text) or bilog (json, text, pbuf)
	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
	// GoPlugin - configuration of executor based on Go plugins
	GoPlugin *GoPlugin
	// PulseLRUSize - configuration of size of a pulse's cache
	PulseLRUSize int
}

LogicRunner configuration

func NewLogicRunner

func NewLogicRunner() LogicRunner

NewLogicRunner - returns default config of the logic runner

type Metrics

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

func NewMetrics() Metrics

NewMetrics creates new default configuration for metrics publishing.

type NetworkConfig

type NetworkConfig struct {
	CommonConfig
	CertificatePath string
	Host            HostNetwork
	Service         ServiceNetwork
}

type Pulsar

type Pulsar struct {
	PulseTime int32 // ms

	NumberDelta uint32

	DistributionTransport Transport
	PulseDistributor      PulseDistributor
}

Pulsar holds configuration for pulsar node.

func NewPulsar

func NewPulsar() Pulsar

NewPulsar creates new default configuration for pulsar node.

type PulsarConfiguration

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

PulsarConfiguration contains configuration params for the pulsar node

func NewPulsarConfiguration

func NewPulsarConfiguration() PulsarConfiguration

NewPulsarConfiguration creates new default configuration for pulsar

type PulsarNodeAddress

type PulsarNodeAddress struct {
	Address   string
	PublicKey string
}

type PulseDistributor

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

type PulseWatcherConfig

type PulseWatcherConfig struct {
	Nodes     []string
	Interval  time.Duration
	Timeout   time.Duration
	Log       Log
	Format    PulseWatcherOutputFormat
	ShowEmoji bool
	OneShot   bool
}

func NewPulseWatcherConfiguration

func NewPulseWatcherConfiguration() PulseWatcherConfig

type PulseWatcherOutputFormat

type PulseWatcherOutputFormat string
const (
	PulseWatcherOutputTxt  PulseWatcherOutputFormat = "text"
	PulseWatcherOutputJSON PulseWatcherOutputFormat = "json"
)

type ServiceNetwork

type ServiceNetwork struct {
	CacheDirectory string
}

ServiceNetwork is configuration for ServiceNetwork.

func NewServiceNetwork

func NewServiceNetwork() ServiceNetwork

NewServiceNetwork creates a new ServiceNetwork configuration.

type StringPathGetter

type StringPathGetter struct {
	Path string
}

func (*StringPathGetter) GetConfigPath

func (g *StringPathGetter) GetConfigPath() string

type TestWalletAPI

type TestWalletAPI struct {
	Address string
}

func NewTestWalletAPI

func NewTestWalletAPI() TestWalletAPI

type Tracer

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

Tracer configures tracer.

func NewTracer

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

type Virtual

type Virtual struct {
	// MaxRunners limits number of contract executions running in parallel.
	// If set to zero or a negative value, limit will be set automatically to
	// `( runtime.NumCPU() - 2 ) but not less then 4`.
	MaxRunners int
}

Virtual holds configuration for virtual.

func NewVirtual

func NewVirtual() Virtual

NewVirtual creates new default virtual configuration.

type VirtualNodeConfig

type VirtualNodeConfig struct {
	CommonAppConfig
	LogicRunner LogicRunner
	Virtual     Virtual
}

Jump to

Keyboard shortcuts

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