@@ -16,6 +16,8 @@ pub struct Config {
16
16
pub bitcoind_rpc_addr : SocketAddr ,
17
17
pub bitcoind_rpc_user : String ,
18
18
pub bitcoind_rpc_password : String ,
19
+ pub rabbitmq_connection_string : String ,
20
+ pub rabbitmq_exchange_name : String ,
19
21
}
20
22
21
23
impl TryFrom < JsonConfig > for Config {
@@ -45,6 +47,16 @@ impl TryFrom<JsonConfig> for Config {
45
47
)
46
48
} ) ?;
47
49
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
+
48
60
Ok ( Config {
49
61
listening_addr,
50
62
network : json_config. network ,
@@ -53,6 +65,8 @@ impl TryFrom<JsonConfig> for Config {
53
65
bitcoind_rpc_addr,
54
66
bitcoind_rpc_user : json_config. bitcoind_rpc_user ,
55
67
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 ( ) ,
56
70
} )
57
71
}
58
72
}
@@ -67,6 +81,8 @@ pub struct JsonConfig {
67
81
bitcoind_rpc_address : String ,
68
82
bitcoind_rpc_user : String ,
69
83
bitcoind_rpc_password : String ,
84
+ rabbitmq_connection_string : Option < String > ,
85
+ rabbitmq_exchange_name : Option < String > ,
70
86
}
71
87
72
88
/// Loads the configuration from a JSON file at the given path.
@@ -114,6 +130,8 @@ mod tests {
114
130
"bitcoind_rpc_address":"127.0.0.1:8332", // comment-1
115
131
"bitcoind_rpc_user": "bitcoind-testuser",
116
132
"bitcoind_rpc_password": "bitcoind-testpassword",
133
+ "rabbitmq_connection_string": "rabbitmq_connection_string",
134
+ "rabbitmq_exchange_name": "rabbitmq_exchange_name",
117
135
"unknown_key": "random-value"
118
136
// comment-2
119
137
}"# ;
@@ -130,6 +148,8 @@ mod tests {
130
148
bitcoind_rpc_addr: SocketAddr :: from_str( "127.0.0.1:8332" ) . unwrap( ) ,
131
149
bitcoind_rpc_user: "bitcoind-testuser" . to_string( ) ,
132
150
bitcoind_rpc_password: "bitcoind-testpassword" . to_string( ) ,
151
+ rabbitmq_connection_string: "rabbitmq_connection_string" . to_string( ) ,
152
+ rabbitmq_exchange_name: "rabbitmq_exchange_name" . to_string( ) ,
133
153
}
134
154
)
135
155
}
0 commit comments