Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogConfig ¶ added in v1.0.9
LogConfig logs the configuration. It logs the configuration in yaml format if config does not implement tConfig or the format is not provided.
func ReadConfig ¶
ReadConfig reads the configuration from the given path and unmarshals it into the given conf. It reads the configuration from the file If conf implements tConfig, it reads the configuration from the reader specified in the configuration. It supports json and yaml formats. If no format is provided, it defaults to yaml. It returns error if any. It returns nil if successful. it is recommended to use config reader for reading configuration from consul, zookeeper, database on production and not use file.
Types ¶
type Config ¶ added in v1.0.1
type Config struct {
Name common.ConfigReaderName
Format common.ConfigFormatType
Consul consul.Config
Zookeeper zookeeper.Config
}
Config represents the configuration for the config reader. Name is the type of the config reader, Expect one of consul, zookeeper, database, file Format is the format of the configuration data, Expect one of json, yaml Consul is the configuration for consul reader Zookeeper is the configuration for zookeeper reader Database is the configuration for database reader File is the configuration for file reader
type ConfigReader ¶ added in v1.0.9
type ConfigReader interface {
// Read reads the configuration from the given path and unmarshals it into the given conf.
// path : path in the configuration store to read the configuration from
// conf : configuration object to unmarshal the data into
// configFormat : format of the configuration data
// returns error if any
// returns nil if successful
Read(ctx context.Context, path string, conf any, configFormat ...common.ConfigFormatType) error
Update(ctx context.Context, path string, conf any, configFormat ...common.ConfigFormatType) error
}
func NewConfigReader ¶ added in v1.0.9
func NewConfigReader(ctx context.Context, conf *Config) (ConfigReader, error)
NewConfigReader creates a new config reader based on the given configuration. it is recommended to use config reader for reading configuration from consul, zookeeper, database on production and not use file.