configutils

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogConfig added in v1.0.9

func LogConfig(ctx context.Context, conf any)

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

func ReadConfig(ctx context.Context, path string, conf any) error

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 `yaml:"Name"`
	Format    common.ConfigFormatType `yaml:"Format"`
	Consul    consul.Config           `yaml:"Consul"`
	Zookeeper zookeeper.Config        `yaml:"Zookeeper"`
}

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.

Directories

Path Synopsis
impls

Jump to

Keyboard shortcuts

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