feat: Add configuration for payment processing, charging engine, metrics, and time-series storage

- Add PaymentConfig with Stripe API key and webhook secret fields
- Add ChargingEngineConfig with base URL and timeout settings
- Add InfluxDBConfig with URL, token, org, and bucket fields
- Add MetricsPort field to ServerConfig for Prometheus metrics endpoint
- Set default values: MetricsPort 9090, ChargingEngine localhost:3001, InfluxDB localhost:8086
- Update Config struct to include Payment, ChargingEngine, and Infl
This commit is contained in:
nutcas3
2026-04-17 15:36:44 +03:00
parent 764e95619b
commit 565052e406
+51 -13
View File
@@ -5,15 +5,30 @@ import (
)
type Config struct {
Server ServerConfig `json:"server"`
Database DatabaseConfig `json:"database"`
Redis RedisConfig `json:"redis"`
IMSI IMSIConfig `json:"imsi"`
ES2 ES2Config `json:"es2"`
Server ServerConfig `json:"server"`
Database DatabaseConfig `json:"database"`
Redis RedisConfig `json:"redis"`
IMSI IMSIConfig `json:"imsi"`
ES2 ES2Config `json:"es2"`
Payment PaymentConfig `json:"payment"`
ChargingEngine ChargingEngineConfig `json:"charging_engine"`
InfluxDB InfluxDBConfig `json:"influxdb"`
}
type ChargingEngineConfig struct {
BaseURL string `json:"base_url"`
Timeout time.Duration `json:"timeout"`
}
type PaymentConfig struct {
Provider string `json:"provider"`
StripeAPIKey string `json:"stripe_api_key"`
StripeWebhookSecret string `json:"stripe_webhook_secret"`
}
type ServerConfig struct {
Port string `json:"port"`
MetricsPort string `json:"metrics_port"`
ReadTimeout time.Duration `json:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout"`
}
@@ -35,15 +50,22 @@ type RedisConfig struct {
}
type IMSIConfig struct {
Prefix string `json:"prefix"`
Prefix string `json:"prefix"`
MinIMSI uint64 `json:"min_imsi"`
MaxIMSI uint64 `json:"max_imsi"`
}
type InfluxDBConfig struct {
URL string `json:"url"`
Token string `json:"token"`
Org string `json:"org"`
Bucket string `json:"bucket"`
}
type ES2Config struct {
BaseURL string `json:"base_url"`
APIKey string `json:"api_key"`
InsecureSkipVerify bool `json:"insecure_skip_verify"`
BaseURL string `json:"base_url"`
APIKey string `json:"api_key"`
InsecureSkipVerify bool `json:"insecure_skip_verify"`
FunctionalityRequesterID string `json:"functionality_requester_id"`
}
@@ -51,6 +73,7 @@ func LoadConfig() *Config {
return &Config{
Server: ServerConfig{
Port: "8000",
MetricsPort: "9090",
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
},
@@ -69,15 +92,30 @@ func LoadConfig() *Config {
DB: 0,
},
IMSI: IMSIConfig{
Prefix: "20893", // France MCC+MNC
Prefix: "20893", // France MCC+MNC
MinIMSI: 1,
MaxIMSI: 999999999,
},
ES2: ES2Config{
BaseURL: "https://smdp.example.com",
APIKey: "",
InsecureSkipVerify: true,
BaseURL: "https://smdp.example.com",
APIKey: "",
InsecureSkipVerify: true,
FunctionalityRequesterID: "telecom-platform",
},
Payment: PaymentConfig{
Provider: "stripe",
StripeAPIKey: "",
StripeWebhookSecret: "",
},
ChargingEngine: ChargingEngineConfig{
BaseURL: "http://localhost:3001",
Timeout: 10 * time.Second,
},
InfluxDB: InfluxDBConfig{
URL: "http://localhost:8086",
Token: "",
Org: "telecom",
Bucket: "telecom",
},
}
}