@@ -262,19 +262,19 @@ impl Default for ApplicationConfig {
262262 }
263263}
264264
265- /// Configuration manager with hot reloading capabilities
266- pub struct ConfigurationManager {
267- /// Current configuration
268- config : Arc < RwLock < ApplicationConfig > > ,
269- /// Configuration file path
270- config_path : PathBuf ,
271- /// File watcher for hot reloading
272- _watcher : Option < RecommendedWatcher > ,
273- /// Configuration change notifications
274- change_tx : mpsc:: UnboundedSender < ConfigurationChange > ,
275- /// Configuration change receiver
276- change_rx : Arc < RwLock < Option < mpsc:: UnboundedReceiver < ConfigurationChange > > > > ,
277- }
265+ /// Configuration manager with hot reloading capabilities
266+ pub struct ConfigurationManager {
267+ /// Current configuration
268+ config : Arc < RwLock < ApplicationConfig > > ,
269+ /// Configuration file path
270+ config_path : PathBuf ,
271+ /// File watcher for hot reloading
272+ _watcher : Option < RecommendedWatcher > ,
273+ /// Configuration change notifications
274+ change_tx : mpsc:: UnboundedSender < ConfigurationChange > ,
275+ /// Configuration change receiver
276+ change_rx : Arc < RwLock < Option < mpsc:: UnboundedReceiver < ConfigurationChange > > > > ,
277+ }
278278
279279/// Configuration change notification
280280#[ derive( Debug , Clone ) ]
@@ -322,21 +322,20 @@ impl ConfigurationManager {
322322 } )
323323 }
324324
325- /// Load configuration from file
326- async fn load_config ( config_path : & Path ) -> ApplicationResult < ApplicationConfig > {
327- let mut config_builder = Config :: builder ( )
328- . add_source ( File :: from ( config_path) . required ( false ) )
329- . add_source ( Environment :: with_prefix ( "TERRAPHIM" ) ) ;
330-
331- // Add default configuration
332- let default_config = ApplicationConfig :: default ( ) ;
333- let default_toml = toml:: to_string ( & default_config)
334- . map_err ( |e| ApplicationError :: ConfigurationError ( e. to_string ( ) ) ) ?;
335-
336- config_builder = config_builder. add_source ( config:: File :: from_str (
337- & default_toml,
338- config:: FileFormat :: Toml ,
339- ) ) ;
325+ /// Load configuration from file
326+ async fn load_config ( config_path : & Path ) -> ApplicationResult < ApplicationConfig > {
327+ // Add default configuration first (base layer)
328+ let default_config = ApplicationConfig :: default ( ) ;
329+ let default_toml = toml:: to_string ( & default_config)
330+ . map_err ( |e| ApplicationError :: ConfigurationError ( e. to_string ( ) ) ) ?;
331+
332+ let config_builder = Config :: builder ( )
333+ . add_source ( config:: File :: from_str (
334+ & default_toml,
335+ config:: FileFormat :: Toml ,
336+ ) )
337+ . add_source ( File :: from ( config_path) . required ( false ) )
338+ . add_source ( Environment :: with_prefix ( "TERRAPHIM" ) ) ;
340339
341340 let config = config_builder
342341 . build ( )
0 commit comments