@@ -4,27 +4,77 @@ import "time"
44
55// Config represents the complete application configuration
66type Config struct {
7- Server ServerConfig `mapstructure:"server"`
8- Tracing TracingConfig `mapstructure:"tracing"`
9- Cache CacheConfig `mapstructure:"cache"`
10- Logger LoggerConfig `mapstructure:"logger"`
11- ErrorTracking ErrorTrackingConfig `mapstructure:"error_tracking"`
12- Middleware MiddlewareConfig `mapstructure:"middleware"`
13- CORS CORSConfig `mapstructure:"cors"`
14- EventBroker EventBrokerConfig `mapstructure:"event_broker"`
15- DBManager DBManagerConfig `mapstructure:"dbmanager"`
16- }
17-
18- // ServerConfig holds server-related configuration
19- type ServerConfig struct {
20- Addr string `mapstructure:"addr"`
7+ Servers ServersConfig `mapstructure:"servers"`
8+ Tracing TracingConfig `mapstructure:"tracing"`
9+ Cache CacheConfig `mapstructure:"cache"`
10+ Logger LoggerConfig `mapstructure:"logger"`
11+ ErrorTracking ErrorTrackingConfig `mapstructure:"error_tracking"`
12+ Middleware MiddlewareConfig `mapstructure:"middleware"`
13+ CORS CORSConfig `mapstructure:"cors"`
14+ EventBroker EventBrokerConfig `mapstructure:"event_broker"`
15+ DBManager DBManagerConfig `mapstructure:"dbmanager"`
16+ Paths PathsConfig `mapstructure:"paths"`
17+ Extensions map [string ]interface {} `mapstructure:"extensions"`
18+ }
19+
20+ // ServersConfig contains configuration for the server manager
21+ type ServersConfig struct {
22+ // DefaultServer is the name of the default server to use
23+ DefaultServer string `mapstructure:"default_server"`
24+
25+ // Instances is a map of server name to server configuration
26+ Instances map [string ]ServerInstanceConfig `mapstructure:"instances"`
27+
28+ // Global timeout defaults (can be overridden per instance)
2129 ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout"`
2230 DrainTimeout time.Duration `mapstructure:"drain_timeout"`
2331 ReadTimeout time.Duration `mapstructure:"read_timeout"`
2432 WriteTimeout time.Duration `mapstructure:"write_timeout"`
2533 IdleTimeout time.Duration `mapstructure:"idle_timeout"`
2634}
2735
36+ // ServerInstanceConfig defines configuration for a single server instance
37+ type ServerInstanceConfig struct {
38+ // Name is the unique name of this server instance
39+ Name string `mapstructure:"name"`
40+
41+ // Host is the host to bind to (e.g., "localhost", "0.0.0.0", "")
42+ Host string `mapstructure:"host"`
43+
44+ // Port is the port number to listen on
45+ Port int `mapstructure:"port"`
46+
47+ // Description is a human-readable description of this server
48+ Description string `mapstructure:"description"`
49+
50+ // GZIP enables GZIP compression middleware
51+ GZIP bool `mapstructure:"gzip"`
52+
53+ // TLS/HTTPS configuration options (mutually exclusive)
54+ // Option 1: Provide certificate and key files directly
55+ SSLCert string `mapstructure:"ssl_cert"`
56+ SSLKey string `mapstructure:"ssl_key"`
57+
58+ // Option 2: Use self-signed certificate (for development/testing)
59+ SelfSignedSSL bool `mapstructure:"self_signed_ssl"`
60+
61+ // Option 3: Use Let's Encrypt / AutoTLS
62+ AutoTLS bool `mapstructure:"auto_tls"`
63+ AutoTLSDomains []string `mapstructure:"auto_tls_domains"`
64+ AutoTLSCacheDir string `mapstructure:"auto_tls_cache_dir"`
65+ AutoTLSEmail string `mapstructure:"auto_tls_email"`
66+
67+ // Timeout configurations (overrides global defaults)
68+ ShutdownTimeout * time.Duration `mapstructure:"shutdown_timeout"`
69+ DrainTimeout * time.Duration `mapstructure:"drain_timeout"`
70+ ReadTimeout * time.Duration `mapstructure:"read_timeout"`
71+ WriteTimeout * time.Duration `mapstructure:"write_timeout"`
72+ IdleTimeout * time.Duration `mapstructure:"idle_timeout"`
73+
74+ // Tags for organization and filtering
75+ Tags map [string ]string `mapstructure:"tags"`
76+ }
77+
2878// TracingConfig holds OpenTelemetry tracing configuration
2979type TracingConfig struct {
3080 Enabled bool `mapstructure:"enabled"`
@@ -136,3 +186,8 @@ type EventBrokerRetryPolicyConfig struct {
136186 MaxDelay time.Duration `mapstructure:"max_delay"`
137187 BackoffFactor float64 `mapstructure:"backoff_factor"`
138188}
189+
190+ // PathsConfig contains configuration for named file system paths
191+ // This is a map of path name to file system path
192+ // Example: "data_dir": "/var/lib/myapp/data"
193+ type PathsConfig map [string ]string
0 commit comments