Documentation ¶
Index ¶
- func ValidateConfig(cfg *Config) error
- type AlloraConfig
- type Config
- type DatabaseConfig
- type FilterEventConfig
- type FilterTransactionConfig
- type KafkaConfig
- type KafkaTopicRouterConfig
- type Loader
- type LogConfig
- type ProducerConfig
- type Provider
- type ViperAdapter
- func (v *ViperAdapter) AddConfigPath(path string)
- func (v *ViperAdapter) AutomaticEnv()
- func (v *ViperAdapter) ConfigFileUsed() string
- func (v *ViperAdapter) ReadInConfig() error
- func (v *ViperAdapter) SetConfigName(name string)
- func (v *ViperAdapter) SetConfigType(configType string)
- func (v *ViperAdapter) SetEnvKeyReplacer(replacer *strings.Replacer)
- func (v *ViperAdapter) SetEnvPrefix(prefix string)
- func (v *ViperAdapter) Unmarshal(rawVal interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateConfig ¶
Types ¶
type AlloraConfig ¶
type Config ¶
type Config struct { Database DatabaseConfig `mapstructure:"database" validate:"required"` Kafka KafkaConfig `mapstructure:"kafka" validate:"required"` Allora AlloraConfig `mapstructure:"allora" validate:"required"` KafkaTopicRouter []KafkaTopicRouterConfig `mapstructure:"kafka_topic_router" validate:"required,gt=0,dive"` FilterEvent FilterEventConfig `mapstructure:"filter_event" validate:"required"` FilterTransaction FilterTransactionConfig `mapstructure:"filter_transaction" validate:"required"` Log LogConfig `mapstructure:"log" validate:"required"` Producer ProducerConfig `mapstructure:"producer" validate:"required"` }
type DatabaseConfig ¶
type DatabaseConfig struct {
URL string `mapstructure:"url" validate:"required,url"` // URL of the database
}
type FilterEventConfig ¶
type FilterEventConfig struct {
Types []string `mapstructure:"types" validate:"required,gt=0,dive,min=1"` // Types of events to filter
}
type FilterTransactionConfig ¶
type FilterTransactionConfig struct {
Types []string `mapstructure:"types" validate:"gt=0,dive,min=1"` // Types of transactions to filter
}
type KafkaConfig ¶
type KafkaTopicRouterConfig ¶
type Loader ¶
type Loader interface { AddConfigPath(path string) SetConfigName(name string) SetConfigType(configType string) SetEnvPrefix(prefix string) SetEnvKeyReplacer(replacer *strings.Replacer) AutomaticEnv() ReadInConfig() error ConfigFileUsed() string Unmarshal(rawVal interface{}) error }
ConfigLoader defines the methods required for configuration loading. This interface abstracts the Viper library to facilitate unit testing.
func NewViperAdapter ¶
func NewViperAdapter() Loader
NewViperAdapter creates a new instance of ViperAdapter.
type LogConfig ¶
type LogConfig struct {
Level int8 `mapstructure:"level" validate:"gte=-1,lte=7"` // Log level
}
type ProducerConfig ¶
type ProducerConfig struct { BlockRefreshInterval time.Duration `mapstructure:"block_refresh_interval" validate:"required"` // Block refresh interval RateLimitInterval time.Duration `mapstructure:"rate_limit_interval" validate:"required"` // Rate limit interval NumWorkers int `mapstructure:"num_workers" validate:"required,gt=0"` // Number of workers to process blocks and block results }
type Provider ¶
func NewProvider ¶
type ViperAdapter ¶
ViperAdapter is a concrete implementation of ConfigLoader using Viper.
func (*ViperAdapter) AddConfigPath ¶
func (v *ViperAdapter) AddConfigPath(path string)
AddConfigPath adds a path for Viper to search for the configuration file.
func (*ViperAdapter) AutomaticEnv ¶
func (v *ViperAdapter) AutomaticEnv()
AutomaticEnv enables Viper to automatically read configuration from environment variables.
func (*ViperAdapter) ConfigFileUsed ¶
func (v *ViperAdapter) ConfigFileUsed() string
ConfigFileUsed returns the file path of the configuration file used.
func (*ViperAdapter) ReadInConfig ¶
func (v *ViperAdapter) ReadInConfig() error
ReadInConfig reads the configuration from the specified file.
func (*ViperAdapter) SetConfigName ¶
func (v *ViperAdapter) SetConfigName(name string)
SetConfigName sets the name of the configuration file without the extension.
func (*ViperAdapter) SetConfigType ¶
func (v *ViperAdapter) SetConfigType(configType string)
SetConfigType sets the type of the configuration file (e.g., "yaml").
func (*ViperAdapter) SetEnvKeyReplacer ¶
func (v *ViperAdapter) SetEnvKeyReplacer(replacer *strings.Replacer)
SetEnvKeyReplacer sets the key replacer for environment variables.
func (*ViperAdapter) SetEnvPrefix ¶
func (v *ViperAdapter) SetEnvPrefix(prefix string)
SetEnvPrefix sets the prefix for environment variables.
func (*ViperAdapter) Unmarshal ¶
func (v *ViperAdapter) Unmarshal(rawVal interface{}) error
Unmarshal unmarshals the configuration into the provided structure.