mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-28 15:42:16 +00:00
feat: Add configuration management for api-server
- Add Config struct with server, database, Redis, IMSI, and ES2+ settings - Add ServerConfig with port and timeout settings (30s read/write) - Add DatabaseConfig for PostgreSQL connection parameters - Add RedisConfig for cache connection settings - Add IMSIConfig with France MCC+MNC prefix (20893) and IMSI range - Add ES2Config for eSIM provisioning with SMDP connection parameters - Add LoadConfig function with default configuration values - Include JSON
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig `json:"server"`
|
||||
Database DatabaseConfig `json:"database"`
|
||||
Redis RedisConfig `json:"redis"`
|
||||
IMSI IMSIConfig `json:"imsi"`
|
||||
ES2 ES2Config `json:"es2"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Port string `json:"port"`
|
||||
ReadTimeout time.Duration `json:"read_timeout"`
|
||||
WriteTimeout time.Duration `json:"write_timeout"`
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Host string `json:"host"`
|
||||
Port string `json:"port"`
|
||||
Database string `json:"database"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
SSLMode string `json:"ssl_mode"`
|
||||
}
|
||||
|
||||
type RedisConfig struct {
|
||||
Host string `json:"host"`
|
||||
Port string `json:"port"`
|
||||
Password string `json:"password"`
|
||||
DB int `json:"db"`
|
||||
}
|
||||
|
||||
type IMSIConfig struct {
|
||||
Prefix string `json:"prefix"`
|
||||
MinIMSI uint64 `json:"min_imsi"`
|
||||
MaxIMSI uint64 `json:"max_imsi"`
|
||||
}
|
||||
|
||||
type ES2Config struct {
|
||||
BaseURL string `json:"base_url"`
|
||||
APIKey string `json:"api_key"`
|
||||
InsecureSkipVerify bool `json:"insecure_skip_verify"`
|
||||
FunctionalityRequesterID string `json:"functionality_requester_id"`
|
||||
}
|
||||
|
||||
func LoadConfig() *Config {
|
||||
return &Config{
|
||||
Server: ServerConfig{
|
||||
Port: "8000",
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 30 * time.Second,
|
||||
},
|
||||
Database: DatabaseConfig{
|
||||
Host: "localhost",
|
||||
Port: "5432",
|
||||
Database: "telecom_platform",
|
||||
Username: "postgres",
|
||||
Password: "password",
|
||||
SSLMode: "disable",
|
||||
},
|
||||
Redis: RedisConfig{
|
||||
Host: "localhost",
|
||||
Port: "6379",
|
||||
Password: "",
|
||||
DB: 0,
|
||||
},
|
||||
IMSI: IMSIConfig{
|
||||
Prefix: "20893", // France MCC+MNC
|
||||
MinIMSI: 1,
|
||||
MaxIMSI: 999999999,
|
||||
},
|
||||
ES2: ES2Config{
|
||||
BaseURL: "https://smdp.example.com",
|
||||
APIKey: "",
|
||||
InsecureSkipVerify: true,
|
||||
FunctionalityRequesterID: "telecom-platform",
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user