stay code :P
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const configFilePath = "config/conf.json"
|
||||
|
||||
type Config struct {
|
||||
Database struct {
|
||||
Host string `json:"host"`
|
||||
@@ -23,14 +25,14 @@ type Config struct {
|
||||
TimeoutMs int `json:"timeout_ms"`
|
||||
Password string `json:"password"`
|
||||
} `json:"valkey"`
|
||||
Temp string `json:"temp"`
|
||||
DatasetId string `json:"dataset_id"`
|
||||
Temp string `json:"temp"`
|
||||
DatasetId string `json:"dataset_id"`
|
||||
ExcludedDatasetIds string `json:"excluded_dataset_ids"`
|
||||
}
|
||||
|
||||
func LoadConfig(file string) (Config, error) {
|
||||
func LoadConfig() (Config, error) {
|
||||
var config Config
|
||||
configFile, err := os.Open(file)
|
||||
configFile, err := os.Open(configFilePath)
|
||||
if err != nil {
|
||||
return config, fmt.Errorf("failed to open config file: %w", err)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func ConnectToPostgreSQL() (*sql.DB, error) {
|
||||
fmt.Println("Connecting to PostgreSQL...")
|
||||
config, err := LoadConfig("config/conf.json")
|
||||
config, err := LoadConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func DisconnectFromPostgreSQL(db *sql.DB) error {
|
||||
}
|
||||
|
||||
func PrintDBConfig() {
|
||||
config, err := LoadConfig("config/conf.json")
|
||||
config, err := LoadConfig()
|
||||
if err != nil {
|
||||
fmt.Println("Error loading config:", err)
|
||||
return
|
||||
|
||||
@@ -17,7 +17,7 @@ type ValkeyConfig struct {
|
||||
Port string `json:"port"`
|
||||
MaxConns int `json:"max_conns"`
|
||||
TimeoutMs int `json:"timeout_ms"`
|
||||
Password string `json:"password"` // Add this line
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
func LoadValkeyConfig(file string) (ValkeyConfig, error) {
|
||||
@@ -56,9 +56,9 @@ func LoadValkeyConfig(file string) (ValkeyConfig, error) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func ConnectToValkey(configPath string) (valkey.Client, error) {
|
||||
func ConnectToValkey() (valkey.Client, error) {
|
||||
fmt.Println("Loading configuration...")
|
||||
config, err := LoadConfig(configPath)
|
||||
config, err := LoadConfig()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load config: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user