@@ -555,9 +555,18 @@ impl Default for DistConfig {
555555pub struct FileConfig {
556556 pub cache : CacheConfigs ,
557557 pub dist : DistConfig ,
558+ // pub timing: ServerTimingConfig,
558559 pub server_startup_timeout_ms : Option < u64 > ,
560+ pub server_shutdown_timeout_ms : Option < u64 > ,
561+ pub port : Option < u16 > ,
559562}
560563
564+ // #[derive(Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
565+ // pub struct ServerTimingConfig {
566+ // pub server_startup_timeout_ms: Option<u64>,
567+ // pub server_shutdown_timeout_ms: Option<u64>,
568+ // }
569+
561570// If the file doesn't exist or we can't read it, log the issue and proceed. If the
562571// config exists but doesn't parse then something is wrong - return an error.
563572pub fn try_read_config_file < T : DeserializeOwned > ( path : & Path ) -> Result < Option < T > > {
@@ -945,7 +954,14 @@ pub struct Config {
945954 pub cache : Option < CacheType > ,
946955 pub fallback_cache : DiskCacheConfig ,
947956 pub dist : DistConfig ,
948- pub server_startup_timeout : Option < std:: time:: Duration > ,
957+ pub server_timing : ServerTiming ,
958+ pub port : Option < u16 > ,
959+ }
960+
961+ #[ derive( Debug , Default , PartialEq , Eq ) ]
962+ pub struct ServerTiming {
963+ pub startup_timeout : Option < std:: time:: Duration > ,
964+ pub shutdown_timeout : Option < std:: time:: Duration > ,
949965}
950966
951967impl Config {
@@ -967,11 +983,20 @@ impl Config {
967983 cache,
968984 dist,
969985 server_startup_timeout_ms,
986+ server_shutdown_timeout_ms,
987+ port,
970988 } = file_conf;
971989 conf_caches. merge ( cache) ;
972990
973991 let server_startup_timeout =
974992 server_startup_timeout_ms. map ( std:: time:: Duration :: from_millis) ;
993+ let server_shutdown_timeout =
994+ server_shutdown_timeout_ms. map ( std:: time:: Duration :: from_millis) ;
995+ let server_timing = ServerTiming {
996+ startup_timeout : server_startup_timeout,
997+ shutdown_timeout : server_shutdown_timeout,
998+ } ;
999+
9751000
9761001 let EnvConfig { cache } = env_conf;
9771002 conf_caches. merge ( cache) ;
@@ -981,7 +1006,8 @@ impl Config {
9811006 cache : caches,
9821007 fallback_cache,
9831008 dist,
984- server_startup_timeout,
1009+ server_timing,
1010+ port,
9851011 }
9861012 }
9871013}
@@ -1281,6 +1307,8 @@ fn config_overrides() {
12811307 } ,
12821308 dist : Default :: default ( ) ,
12831309 server_startup_timeout_ms : None ,
1310+ server_shutdown_timeout_ms : None ,
1311+ port : None ,
12841312 } ;
12851313
12861314 assert_eq ! (
@@ -1302,7 +1330,8 @@ fn config_overrides() {
13021330 rw_mode: CacheModeConfig :: ReadWrite ,
13031331 } ,
13041332 dist: Default :: default ( ) ,
1305- server_startup_timeout: None ,
1333+ server_timing: Default :: default ( ) ,
1334+ port: None ,
13061335 }
13071336 ) ;
13081337}
@@ -1577,7 +1606,26 @@ no_credentials = true
15771606 toolchain_cache_size: 5368709120 ,
15781607 rewrite_includes_only: false ,
15791608 } ,
1580- server_startup_timeout_ms: Some ( 10000 ) ,
1609+ server_startup_timeout_ms: Some ( 10_000 ) ,
1610+ server_shutdown_timeout_ms: None ,
1611+ port: None ,
1612+ }
1613+ )
1614+ }
1615+
1616+ #[ test]
1617+ fn test_port_config ( ) {
1618+ // just set up a config file with just port, then have it read it in, and ensure port is defined in the struct
1619+ const CONFIG_STR : & str = "port = 8080" ;
1620+ let file_config: FileConfig = toml:: from_str ( CONFIG_STR ) . expect ( "Is valid toml." ) ;
1621+ assert_eq ! (
1622+ file_config,
1623+ FileConfig {
1624+ cache: Default :: default ( ) ,
1625+ dist: Default :: default ( ) ,
1626+ server_startup_timeout_ms: None ,
1627+ server_shutdown_timeout_ms: None ,
1628+ port: Some ( 8080 ) ,
15811629 }
15821630 )
15831631}
0 commit comments