config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagEnv  = "env"
	TagFlag = "flag"
	TagDesc = "desc"

	StrFlagNotDefined = "flag provided but not defined"
)

Variables

View Source
var (
	BuildVersion = "TO BE SET AT BUILD TIME"
	Commit       = "TO BE SET AT BUILD TIME"
)
View Source
var (
	ErrEnvLoad          = errors.New("error during loading .env file")
	ErrEnvParse         = errors.New("cannot parse env variable")
	ErrFlagParse        = errors.New("cannot parse flag")
	ErrConfigInvalid    = errors.New("invalid config struct")
	ErrConfigValidation = errors.New("config validation error")
)

Functions

func LoadConfig

func LoadConfig(cfg ConfigInterface, osArgs *[]string) error

func NewValidator

func NewValidator() (*validator.Validate, error)

Types

type Config

type Config struct {
	Blockchain struct {
		EthNodeAddress string `env:"ETH_NODE_ADDRESS"   flag:"eth-node-address"   validate:"required,url"`
		EthLegacyTx    bool   `env:"ETH_NODE_LEGACY_TX" flag:"eth-node-legacy-tx" desc:"use it to disable EIP-1559 transactions"`
	}
	Environment string `env:"ENVIRONMENT" flag:"environment"`
	Hashrate    struct {
		CycleDuration             time.Duration `` /* 230-byte string literal not displayed */
		ErrorThreshold            float64       `` /* 235-byte string literal not displayed */
		PeerValidationInterval    time.Duration `` /* 191-byte string literal not displayed */
		ShareTimeout              time.Duration `` /* 208-byte string literal not displayed */
		ValidatorFlatness         time.Duration `` /* 189-byte string literal not displayed */
		ValidationTimeoutAppStart time.Duration `` /* 232-byte string literal not displayed */
		ValidationAutoClaimReward bool          `` /* 195-byte string literal not displayed */
	}
	Marketplace struct {
		CloneFactoryAddress      string `env:"CLONE_FACTORY_ADDRESS" flag:"contract-address"   validate:"required_if=Disable false,omitempty,eth_addr"`
		ValidatorRegistryAddress string `env:"VALIDATOR_REGISTRY_ADDRESS" flag:"validator-registry-address" validate:"omitempty,eth_addr"`
		Mnemonic                 string `env:"CONTRACT_MNEMONIC"     flag:"contract-mnemonic"  validate:"required_without=WalletPrivateKey|required_if=Disable false"`
		WalletPrivateKey         string `env:"WALLET_PRIVATE_KEY"    flag:"wallet-private-key" validate:"required_without=Mnemonic|required_if=Disable false"`
	}
	Miner struct {
		NotPropagateWorkerName bool          `` /* 309-byte string literal not displayed */
		IdleReadTimeout        time.Duration `` /* 213-byte string literal not displayed */
		VettingShares          int           `env:"MINER_VETTING_SHARES"            flag:"miner-vetting-shares"                validate:"omitempty,number"`
	}
	Log struct {
		Color           bool   `env:"LOG_COLOR"            flag:"log-color"`
		FolderPath      string `` /* 139-byte string literal not displayed */
		IsProd          bool   `` /* 130-byte string literal not displayed */
		JSON            bool   `env:"LOG_JSON"             flag:"log-json"`
		LevelApp        string `env:"LOG_LEVEL_APP"        flag:"log-level-app"        validate:"omitempty,oneof=debug info warn error dpanic panic fatal"`
		LevelConnection string `env:"LOG_LEVEL_CONNECTION" flag:"log-level-connection" validate:"omitempty,oneof=debug info warn error dpanic panic fatal"`
		LevelProxy      string `env:"LOG_LEVEL_PROXY"      flag:"log-level-proxy"      validate:"omitempty,oneof=debug info warn error dpanic panic fatal"`
		LevelScheduler  string `env:"LOG_LEVEL_SCHEDULER"  flag:"log-level-scheduler"  validate:"omitempty,oneof=debug info warn error dpanic panic fatal"`
		LevelContract   string `env:"LOG_LEVEL_CONTRACT"   flag:"log-level-contract"   validate:"omitempty,oneof=debug info warn error dpanic panic fatal"`
	}
	Pool struct {
		Address          string        `env:"POOL_ADDRESS" flag:"pool-address" validate:"required,uri"`
		CleanJobTimeout  time.Duration `` /* 199-byte string literal not displayed */
		IdleWriteTimeout time.Duration `` /* 166-byte string literal not displayed */
	}
	Proxy struct {
		Address        string `env:"PROXY_ADDRESS" flag:"proxy-address" validate:"required,hostname_port"`
		MaxCachedDests int    `` /* 140-byte string literal not displayed */
	}
	System struct {
		Enable           bool   `env:"SYS_ENABLE"              flag:"sys-enable" desc:"enable system level configuration adjustments"`
		LocalPortRange   string `env:"SYS_LOCAL_PORT_RANGE"    flag:"sys-local-port-range"    desc:""`
		NetdevMaxBacklog string `env:"SYS_NET_DEV_MAX_BACKLOG" flag:"sys-netdev-max-backlog"  desc:""`
		RlimitHard       uint64 `env:"SYS_RLIMIT_HARD"         flag:"sys-rlimit-hard"         desc:""`
		RlimitSoft       uint64 `env:"SYS_RLIMIT_SOFT"         flag:"sys-rlimit-soft"         desc:""`
		Somaxconn        string `env:"SYS_SOMAXCONN"           flag:"sys-somaxconn"           desc:""`
		TcpMaxSynBacklog string `env:"SYS_TCP_MAX_SYN_BACKLOG" flag:"sys-tcp-max-syn-backlog" desc:""`
	}
	Web struct {
		Address   string `env:"WEB_ADDRESS"    flag:"web-address"    validate:"required,hostname_port" desc:"http server address host:port"`
		PublicUrl string `` /* 150-byte string literal not displayed */
	}
}

Validation tags described here: https://pkg.go.dev/github.com/go-playground/validator/v10

func (*Config) GetSanitized

func (cfg *Config) GetSanitized() interface{}

GetSanitized returns a copy of the config with sensitive data removed explicitly adding each field here to avoid accidentally leaking sensitive data

func (*Config) SetDefaults

func (cfg *Config) SetDefaults()

type ConfigInterface

type ConfigInterface interface {
	SetDefaults()
}

type DerivedConfig

type DerivedConfig struct {
	WalletAddress  string
	LumerinAddress string
}

Jump to

Keyboard shortcuts

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