File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
- use anyhow:: Context ;
1
+ use anyhow:: { anyhow , Context } ;
2
2
use std:: net:: SocketAddr ;
3
3
use std:: sync:: Arc ;
4
4
use tokio:: {
@@ -57,11 +57,18 @@ impl ChaosProxy {
57
57
. context ( "could not resolve database url" ) ?
58
58
. first ( )
59
59
. copied ( )
60
- . ok_or_else ( || anyhow:: anyhow!( "the database url does not point to any IP" ) ) ?;
60
+ . ok_or_else ( || anyhow ! ( "the database url does not point to any IP" ) ) ?;
61
+
62
+ let instance = ChaosProxy :: new ( backend_addr) ?;
63
+
64
+ db_url
65
+ . set_ip_host ( instance. address . ip ( ) )
66
+ . map_err ( |_| anyhow ! ( "Failed to set IP host on the URL" ) ) ?;
67
+
68
+ db_url
69
+ . set_port ( Some ( instance. address . port ( ) ) )
70
+ . map_err ( |_| anyhow ! ( "Failed to set post on the URL" ) ) ?;
61
71
62
- let instance = ChaosProxy :: new ( backend_addr) . unwrap ( ) ;
63
- db_url. set_ip_host ( instance. address . ip ( ) ) . unwrap ( ) ;
64
- db_url. set_port ( Some ( instance. address . port ( ) ) ) . unwrap ( ) ;
65
72
Ok ( ( instance, db_url. into ( ) ) )
66
73
}
67
74
You can’t perform that action at this time.
0 commit comments