code.vegaprotocol.io/vega@v0.79.0/datanode/config/README.md (about)

     1  # Config
     2  
     3  Config is a central place where all sub-system specific configurations come together. Sub-system specific config are defined on each corresponding packages.
     4  The CLI defines all its parameters as structs. Out of this structs we generate a configuration file (in [toml](https://github.com/toml-lang/toml) format) and CLI flags (via [go-flags](github.com/jessevdk/go-flags)).
     5  
     6  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.
     7  
     8  ## How to use it
     9  Structs define fields which maps to parameters:
    10  
    11  ```go
    12  // Config is the configuration of the execution package
    13  type Config struct {
    14    ...
    15    Level encoding.LogLevel             `long:"log-level"`
    16    InsurancePoolInitialBalance uint64  `long:"insurance-pool-initial-balance" description:"Some description"`
    17    Matching   matching.Config          `group:"Matching" namespace:"matching"`
    18    ...
    19  }
    20  ```
    21  
    22  A Config struct can hold native to types like `uint64`, custom types like `encoding.LogLevel` and other structures like `matching.Config`.
    23  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.
    24  These are the two main tag that we use, see [Availabl field tags](https://godoc.org/github.com/jessevdk/go-flags#hdr-Available_field_tags) for reference.
    25  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.
    26  In this case the Matching options are going to be prefixed with the `--matching.` See [matching.Config]() for reference
    27  ```
    28  $ vega node --help
    29  Usage:
    30    vega [OPTIONS] node [node-OPTIONS]
    31  
    32  Runs a vega node
    33  
    34      Execution:
    35            --execution.log-level=
    36            --execution.insurance-pool-initial-balance=         Some description (default: 
    37  
    38      Execution::Matching:
    39            --execution.matching.log-level=
    40            --execution.matching.log-price-levels-debug
    41            --execution.matching.log-removed-orders-debug
    42  ```
    43  
    44  ### Default values
    45  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](https://dave.cheney.net/2013/01/19/what-is-the-zero-value-and-why-is-it-useful)
    46