config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	General      GeneralConfig          `mapstructure:"general"`
	WorkerConfig WorkerConfig           `mapstructure:"worker"`
	Logging      logtypes.LoggingConfig `mapstructure:"logging"`
}

AppConfig is the structure representation of configuration from `config.yaml` file

func LoadAppConfig

func LoadAppConfig(homeDir string) (*AppConfig, error)

LoadAppConfig load the configuration from `config.yaml` file within the specified application's home directory

func (AppConfig) PrintOptions

func (c AppConfig) PrintOptions()

PrintOptions prints the configuration in the `config.yaml` in a nice way, human-readable

func (AppConfig) Validate

func (c AppConfig) Validate() error

Validate performs validation on the configuration specified in the `config.yaml` within application's home directory

type AppContext

type AppContext struct {
	AppConfig AppConfig
	Logger    logging.Logger
}

AppContext hold the working context of the application entirely. It contains application configuration, logger,...

func NewAppContext

func NewAppContext(conf *AppConfig) *AppContext

NewAppContext inits `AppContext` with needed information to be stored within and return it

type ChainConfig

type ChainConfig struct {
	ChainName  string                           `mapstructure:"chain-name"`
	ChainId    string                           `mapstructure:"chain-id"`
	Disable    bool                             `mapstructure:"disable,omitempty"`
	Priority   bool                             `mapstructure:"priority,omitempty"`
	RPCs       []string                         `mapstructure:"rpc"`
	Validators map[string]*ChainValidatorConfig `mapstructure:"validators"`
}

func (ChainConfig) Validate

func (c ChainConfig) Validate() error

type ChainValidatorConfig

type ChainValidatorConfig struct {
	ValidatorOperatorAddress string   `mapstructure:"-"`
	Watchers                 []string `mapstructure:"watchers"`
	OptionalHealthCheckRPC   string   `mapstructure:"health-check-rpc,omitempty"` // if provided, do health-check directly to this endpoint
}

type ChainsConfig

type ChainsConfig []ChainConfig

func LoadChainsConfig

func LoadChainsConfig(homeDir string) (ChainsConfig, error)

LoadChainsConfig load the configuration from `chain.*.yaml` file within the specified application's home directory

func (ChainsConfig) SortByPriority

func (c ChainsConfig) SortByPriority() ChainsConfig

func (ChainsConfig) Validate

func (c ChainsConfig) Validate(usersConfig *UsersConfig) error

type GeneralConfig

type GeneralConfig struct {
	HotReloadInterval   time.Duration `mapstructure:"hot-reload"`
	HealthCheckInterval time.Duration `mapstructure:"health-check"`
}

type UserRecord

type UserRecord struct {
	Identity       string              `mapstructure:"-"`
	Root           bool                `mapstructure:"root"`
	TelegramConfig *UserTelegramConfig `mapstructure:"telegram,omitempty"`
}

func (UserRecord) Validate

func (r UserRecord) Validate() error

type UserRecords

type UserRecords []UserRecord

func (UserRecords) Validate

func (r UserRecords) Validate() error

type UserTelegramConfig

type UserTelegramConfig struct {
	Username string `mapstructure:"username"`
	UserId   int64  `mapstructure:"id"`
	Token    string `mapstructure:"token"` // token used to send message to this user
}

func (*UserTelegramConfig) IsEmptyOrIncompleteConfig

func (c *UserTelegramConfig) IsEmptyOrIncompleteConfig() bool

type UsersConfig

type UsersConfig struct {
	Users map[string]UserRecord `mapstructure:"users"`
}

func LoadUsersConfig

func LoadUsersConfig(homeDir string) (*UsersConfig, error)

LoadUsersConfig load the configuration from `users.yaml` file within the specified application's home directory

func (UsersConfig) ToUserRecords

func (c UsersConfig) ToUserRecords() UserRecords

type WorkerConfig

type WorkerConfig struct {
	HealthCheckCount int `mapstructure:"health-check-count"`
}

Jump to

Keyboard shortcuts

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