Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// Listen specifies the address and port on which the application should listen for incoming requests.
Listen string `toml:"listen"`
// WorkerCount specifies the number of worker routines that the application should spawn.
WorkerCount int `toml:"workerCount"`
}
App holds configuration parameters related to the application itself.
type Config ¶
type Config struct {
// App holds the application-specific configuration, such as the address to listen on and the number of worker routines.
App App `toml:"app"`
// DataBase holds database connection settings, such as the URL, connection timeout, and pool size.
DataBase DataBase `toml:"database"`
// Redis holds the Redis connection configuration, including Redis server addresses, pool size, and timeout settings.
Redis Redis `toml:"redis"`
// contains filtered or unexported fields
}
Config holds the overall configuration for the application, including settings for the application itself, the database, and Redis. It uses TOML (Tom's Obvious, Minimal Language) tags to define the structure of the configuration file.
func NewConfig ¶
NewConfig is a constructor function that returns a new Config object with the specified file path. The file path will later be used to load configuration settings from a TOML file.
func (*Config) Load ¶
Load reads the configuration from the TOML file specified by the filePath field in the Config struct. This method attempts to decode the file into the Config struct, ensuring that all necessary configuration values are loaded for the application. If an error occurs during file reading or decoding, the method returns an error indicating the problem.
type DataBase ¶
type DataBase struct {
// URL is the database connection string used to connect to the database.
URL string `toml:"url"`
// ConnectTimeout is the timeout (in seconds) for establishing a connection to the database.
ConnectTimeout int `toml:"connect_timeout"`
// PoolSize specifies the number of database connections in the connection pool.
PoolSize int `toml:"pool_size"`
}
DataBase defines the database connection settings.
type Redis ¶
type Redis struct {
// Redis is a list of Redis server addresses.
Redis []string `toml:"redis"`
// ConnectionSize specifies the size of the Redis connection pool.
ConnectionSize int `toml:"pool_size"`
// DialTimeout specifies the maximum duration (in seconds) to wait for a Redis connection to be established.
DialTimeout int64 `toml:"dial_timeout"`
// WriteTimeout specifies the maximum duration (in seconds) to wait for writing data to a Redis connection.
WriteTimeout int64 `toml:"write_timeout"`
// ReadTimeout specifies the maximum duration (in seconds) to wait for reading data from a Redis connection.
ReadTimeout int64 `toml:"read_timeout"`
}
Redis holds configuration parameters for connecting to multiple Redis instances.