@@ -16,6 +16,8 @@ pub struct Config {
1616 pub bitcoind_rpc_addr : SocketAddr ,
1717 pub bitcoind_rpc_user : String ,
1818 pub bitcoind_rpc_password : String ,
19+ pub rabbitmq_connection_string : String ,
20+ pub rabbitmq_exchange_name : String ,
1921}
2022
2123impl TryFrom < JsonConfig > for Config {
@@ -45,6 +47,16 @@ impl TryFrom<JsonConfig> for Config {
4547 )
4648 } ) ?;
4749
50+ #[ cfg( feature = "events-rabbitmq" ) ]
51+ if json_config. rabbitmq_connection_string . as_deref ( ) . map_or ( true , |s| s. is_empty ( ) )
52+ || json_config. rabbitmq_exchange_name . as_deref ( ) . map_or ( true , |s| s. is_empty ( ) )
53+ {
54+ return Err ( io:: Error :: new (
55+ io:: ErrorKind :: InvalidInput ,
56+ "Both `rabbitmq_connection_string` and `rabbitmq_exchange_name` must be configured if enabling `events-rabbitmq` feature." . to_string ( ) ,
57+ ) ) ;
58+ }
59+
4860 Ok ( Config {
4961 listening_addr,
5062 network : json_config. network ,
@@ -53,6 +65,8 @@ impl TryFrom<JsonConfig> for Config {
5365 bitcoind_rpc_addr,
5466 bitcoind_rpc_user : json_config. bitcoind_rpc_user ,
5567 bitcoind_rpc_password : json_config. bitcoind_rpc_password ,
68+ rabbitmq_connection_string : json_config. rabbitmq_connection_string . unwrap_or_default ( ) ,
69+ rabbitmq_exchange_name : json_config. rabbitmq_exchange_name . unwrap_or_default ( ) ,
5670 } )
5771 }
5872}
@@ -67,6 +81,8 @@ pub struct JsonConfig {
6781 bitcoind_rpc_address : String ,
6882 bitcoind_rpc_user : String ,
6983 bitcoind_rpc_password : String ,
84+ rabbitmq_connection_string : Option < String > ,
85+ rabbitmq_exchange_name : Option < String > ,
7086}
7187
7288/// Loads the configuration from a JSON file at the given path.
@@ -130,6 +146,8 @@ mod tests {
130146 bitcoind_rpc_addr: SocketAddr :: from_str( "127.0.0.1:8332" ) . unwrap( ) ,
131147 bitcoind_rpc_user: "bitcoind-testuser" . to_string( ) ,
132148 bitcoind_rpc_password: "bitcoind-testpassword" . to_string( ) ,
149+ rabbitmq_connection_string: "" . to_string( ) ,
150+ rabbitmq_exchange_name: "" . to_string( ) ,
133151 }
134152 )
135153 }
0 commit comments