mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-15 00:15:13 +00:00
* refactor: Rename handler package to handlers in carrier-connector - Rename internal/handler directory to internal/handlers - Update handler import path in main.go and routes.go * feat: Add SM-DP+ handler with multi-carrier management and profile operations - Add SMDPHandler struct with manager field and NewSMDPHandler constructor - Add AddCarrier endpoint with JSON binding and carrier configuration support - Add RemoveCarrier endpoint with carrier ID parameter validation - Add DownloadProfile endpoint with 30-second timeout and context cancellation - Add GetCarrierStatus endpoint returning all carriers with timestamp - Add GetProfileStatus endpoint with EID/ICCID validation * feat: Add SM-DP+ integration layer with multi-carrier system initialization and route registration - Add SMDPIntegration struct with service, handler, repository, and logger fields - Add NewSMDPIntegration constructor with default carrier initialization - Add InitializeSystem method with carrier health logging and status tracking - Add RegisterRoutes method with profile, carrier, health, and metrics endpoints - Add healthHandler with carrier health status aggregation and degraded state detection - Add metricsHandler * feat: Add SM-DP+ service layer with multi-carrier management and profile download operations - Add SMDPService struct with manager, repository, and logger fields - Add NewSMDPService constructor with default config and background health checking - Add InitializeDefaultCarriers with AT&T, Verizon, and T-Mobile DE configurations - Add DownloadProfile method with context support and request logging - Add GetOptimalCarrier wrapping SelectCarrier for best carrier selection - Add GetCarrierHealth returning * feat: Add SM-DP+ manager with multi-carrier load balancing, health checking, and profile operations - Add DefaultManagerConfig with 30s health checks, 3 retries, and circuit breaker configuration - Add CarrierConfig struct with ES2 settings, MCC/MNC, priority, and feature support - Add ToCarrier method converting CarrierConfig to Carrier with metrics and capabilities - Add HealthChecker with periodic carrier health monitoring and status evaluation - Add LoadBalancer with weighted round-robin, least
78 lines
2.8 KiB
Go
78 lines
2.8 KiB
Go
package smdp
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/config"
|
|
)
|
|
|
|
// DefaultManagerConfig returns default configuration for SM-DP+ Manager
|
|
func DefaultManagerConfig() *ManagerConfig {
|
|
return &ManagerConfig{
|
|
HealthCheckInterval: 30 * time.Second,
|
|
MaxRetries: 3,
|
|
RetryDelay: 2 * time.Second,
|
|
CircuitBreakerThreshold: 5,
|
|
CircuitBreakerTimeout: 60 * time.Second,
|
|
EnableLoadBalancing: true,
|
|
EnableFailover: true,
|
|
DefaultTimeout: 30 * time.Second,
|
|
}
|
|
}
|
|
|
|
// CarrierConfig represents carrier configuration from database or config file
|
|
type CarrierConfig struct {
|
|
ID string `json:"id" yaml:"id"`
|
|
Name string `json:"name" yaml:"name"`
|
|
CountryCode string `json:"country_code" yaml:"country_code"`
|
|
MCC string `json:"mcc" yaml:"mcc"`
|
|
MNC string `json:"mnc" yaml:"mnc"`
|
|
ES2BaseURL string `json:"es2_base_url" yaml:"es2_base_url"`
|
|
ES2APIKey string `json:"es2_api_key" yaml:"es2_api_key"`
|
|
ES2InsecureSkip bool `json:"es2_insecure_skip" yaml:"es2_insecure_skip"`
|
|
Priority int `json:"priority" yaml:"priority"`
|
|
IsActive bool `json:"is_active" yaml:"is_active"`
|
|
MaxConcurrentReqs int `json:"max_concurrent_requests" yaml:"max_concurrent_requests"`
|
|
SupportedProfileTypes []string `json:"supported_profile_types" yaml:"supported_profile_types"`
|
|
SupportedMCCs []string `json:"supported_mccs" yaml:"supported_mccs"`
|
|
SupportedMNCs []string `json:"supported_mncs" yaml:"supported_mncs"`
|
|
Features []string `json:"features" yaml:"features"`
|
|
}
|
|
|
|
// ToCarrier converts CarrierConfig to Carrier struct
|
|
func (c *CarrierConfig) ToCarrier() *Carrier {
|
|
carrier := &Carrier{
|
|
ID: c.ID,
|
|
Name: c.Name,
|
|
CountryCode: c.CountryCode,
|
|
MCC: c.MCC,
|
|
MNC: c.MNC,
|
|
Priority: c.Priority,
|
|
IsActive: c.IsActive,
|
|
HealthStatus: CarrierStatusUnknown,
|
|
LastHealthCheck: time.Now(),
|
|
Metrics: &CarrierMetrics{
|
|
TotalRequests: 0,
|
|
SuccessfulRequests: 0,
|
|
FailedRequests: 0,
|
|
AverageResponseTime: 0,
|
|
RequestRate: 0,
|
|
},
|
|
Capabilities: &CarrierCapabilities{
|
|
SupportedProfileTypes: c.SupportedProfileTypes,
|
|
MaxConcurrentRequests: c.MaxConcurrentReqs,
|
|
SupportedMCCs: c.SupportedMCCs,
|
|
SupportedMNCs: c.SupportedMNCs,
|
|
Features: c.Features,
|
|
},
|
|
ES2Config: &config.ES2Config{
|
|
BaseURL: c.ES2BaseURL,
|
|
APIKey: c.ES2APIKey,
|
|
InsecureSkipVerify: c.ES2InsecureSkip,
|
|
FunctionalityRequesterID: "telecom-platform",
|
|
},
|
|
}
|
|
|
|
return carrier
|
|
}
|