@@ -134,6 +134,7 @@ impl Default for QueryRouter {
134
134
135
135
#[ derive( Deserialize , Debug , Clone ) ]
136
136
pub struct Config {
137
+ pub path : Option < String > ,
137
138
pub general : General ,
138
139
pub user : User ,
139
140
pub shards : HashMap < String , Shard > ,
@@ -143,6 +144,7 @@ pub struct Config {
143
144
impl Default for Config {
144
145
fn default ( ) -> Config {
145
146
Config {
147
+ path : Some ( String :: from ( "pgcat.toml" ) ) ,
146
148
general : General :: default ( ) ,
147
149
user : User :: default ( ) ,
148
150
shards : HashMap :: from ( [ ( String :: from ( "1" ) , Shard :: default ( ) ) ] ) ,
@@ -189,7 +191,7 @@ pub async fn parse(path: &str) -> Result<(), Error> {
189
191
}
190
192
} ;
191
193
192
- let config: Config = match toml:: from_str ( & contents) {
194
+ let mut config: Config = match toml:: from_str ( & contents) {
193
195
Ok ( config) => config,
194
196
Err ( err) => {
195
197
error ! ( "Could not parse config file: {}" , err. to_string( ) ) ;
@@ -279,6 +281,8 @@ pub async fn parse(path: &str) -> Result<(), Error> {
279
281
}
280
282
} ;
281
283
284
+ config. path = Some ( path. to_string ( ) ) ;
285
+
282
286
CONFIG . store ( Arc :: new ( config. clone ( ) ) ) ;
283
287
284
288
Ok ( ( ) )
@@ -296,5 +300,6 @@ mod test {
296
300
assert_eq ! ( get_config( ) . shards[ "1" ] . servers[ 0 ] . 0 , "127.0.0.1" ) ;
297
301
assert_eq ! ( get_config( ) . shards[ "0" ] . servers[ 0 ] . 2 , "primary" ) ;
298
302
assert_eq ! ( get_config( ) . query_router. default_role, "any" ) ;
303
+ assert_eq ! ( get_config( ) . path, Some ( "pgcat.toml" . to_string( ) ) ) ;
299
304
}
300
305
}
0 commit comments