config

package
v0.74.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: AGPL-3.0 Imports: 22 Imported by: 1

README

Config

Config is a central place where all sub-system specific configurations come together. Sub-system specific config are defined on each corresponding packages. The CLI defines all its parameters as structs. Out of this structs we generate a configuration file (in toml format) and CLI flags (via go-flags).

Ideally all parameters defined in the toml config should be exposed via flags, we might have a case where a parameter exists as a flag but not in the config, like -c | --config which defines the path of the config. Thereby, cli flags are a super set of the config parameters.

How to use it

Structs define fields which maps to parameters:

// Config is the configuration of the execution package
type Config struct {
  ...
  Level encoding.LogLevel             `long:"log-level"`
  InsurancePoolInitialBalance uint64  `long:"insurance-pool-initial-balance" description:"Some description"`
  Matching   matching.Config          `group:"Matching" namespace:"matching"`
  ...
}

A Config struct can hold native to types like uint64, custom types like encoding.LogLevel and other structures like matching.Config. The long:log-level tag will be mapped to a --log-level= flag, also the description: tag will be displayed as documentation for that particular flag. These are the two main tag that we use, see Availabl field tags for reference. When there are nested structs, we use the group and namespace tag. While the group tag will be displayed in the help to group the documentation, the namespace tag will affect the final flag name. In this case the Matching options are going to be prefixed with the --matching. See matching.Config for reference

$ vega node --help
Usage:
  vega [OPTIONS] node [node-OPTIONS]

Runs a vega node

    Execution:
          --execution.log-level=
          --execution.insurance-pool-initial-balance=         Some description (default: 

    Execution::Matching:
          --execution.matching.log-level=
          --execution.matching.log-price-levels-debug
          --execution.matching.log-removed-orders-debug
Default values

Default values are displayed in the help if a) description annotation is set and b) if the value of the parameter is anything different from its zero value

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Admin     admin.Config     `group:"Admin"     namespace:"admin"`
	API       api.Config       `group:"API"       namespace:"api"`
	CandlesV2 candlesv2.Config `group:"CandlesV2" namespace:"candlesv2"`
	Logging   logging.Config   `group:"Logging"   namespace:"logging"`
	SQLStore  sqlstore.Config  `group:"Sqlstore"  namespace:"sqlstore"`
	Gateway   gateway.Config   `group:"Gateway"   namespace:"gateway"`
	Metrics   metrics.Config   `group:"Metrics"   namespace:"metrics"`
	Broker    broker.Config    `group:"Broker"    namespace:"broker"`
	Service   service.Config   `group:"Service"   namespace:"service"`

	Pprof          pprof.Config  `group:"Pprof" namespace:"pprof"`
	GatewayEnabled encoding.Bool `choice:"true" choice:"false"    description:" " long:"gateway-enabled"`

	NetworkHistory                   networkhistory.Config `group:"NetworkHistory" namespace:"networkhistory"`
	AutoInitialiseFromNetworkHistory encoding.Bool         `` /* 196-byte string literal not displayed */

	ChainID          string `long:"chainID"`
	MaxMemoryPercent uint8  `description:"The maximum amount of memory reserved for the data node (default: 33%)" long:"max-memory-percent"`
}

Config ties together all other application configuration types.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig returns a set of default configs for all vega packages, as specified at the per package config level, if there is an error initialising any of the configs then this is returned.

func (Config) GetMaxMemoryFactor added in v0.66.0

func (c Config) GetMaxMemoryFactor() (float64, error)

type Empty

type Empty struct{}

Empty is used when a command or sub-command receives no argument and has no execution.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func InitialiseLoader

func InitialiseLoader(vegaPaths paths.Paths) (*Loader, error)

func (*Loader) ConfigExists

func (l *Loader) ConfigExists() (bool, error)

func (*Loader) ConfigFilePath

func (l *Loader) ConfigFilePath() string

func (*Loader) Get

func (l *Loader) Get() (*Config, error)

func (*Loader) Remove

func (l *Loader) Remove()

func (*Loader) Save

func (l *Loader) Save(cfg *Config) error

type Option

type Option func(w *Watcher)

func Use

func Use(use func(*Config) error) Option

type VegaHomeFlag

type VegaHomeFlag struct {
	VegaHome string `description:"Path to the custom home for vega" long:"home"`
}

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is looking for updates in the configurations files.

func NewWatcher

func NewWatcher(ctx context.Context, log *logging.Logger, vegaPaths paths.Paths, opts ...Option) (*Watcher, error)

NewWatcher instantiate a new watcher from the vega config files.

func (*Watcher) Get

func (w *Watcher) Get() Config

Get return the last update of the configuration.

func (*Watcher) OnConfigUpdate

func (w *Watcher) OnConfigUpdate(fns ...func(Config))

OnConfigUpdate register a function to be called when the configuration is getting updated.

func (*Watcher) OnTimeUpdate

func (w *Watcher) OnTimeUpdate(_ context.Context, _ time.Time)

func (*Watcher) Use

func (w *Watcher) Use(fns ...func(*Config) error)

Use registers a function that modify the config when the configuration is updated.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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