Allow configuring vhost
This commit is contained in:
parent
c6855b5fd3
commit
7eb39889c3
|
@ -33,6 +33,7 @@ pub struct FeedbackConfig {
|
|||
pub struct RabbitMQConfig {
|
||||
pub ssl: bool,
|
||||
pub host: String,
|
||||
pub virtualhost: Option<String>,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
@ -118,11 +119,12 @@ impl Config {
|
|||
impl RabbitMQConfig {
|
||||
pub fn as_uri(&self) -> String {
|
||||
return format!(
|
||||
"{}://{}:{}@{}//",
|
||||
"{}://{}:{}@{}/{}",
|
||||
if self.ssl { "amqps" } else { "amqp" },
|
||||
self.username,
|
||||
self.password,
|
||||
self.host
|
||||
self.host,
|
||||
self.virtualhost.clone().unwrap_or("/".to_owned()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ pub fn session_from_config(config: &RabbitMQConfig) -> Result<amqp::Session, amq
|
|||
amqp::AMQPScheme::AMQPS => 5671,
|
||||
amqp::AMQPScheme::AMQP => 5672,
|
||||
},
|
||||
vhost: "/".to_owned(),
|
||||
vhost: config.virtualhost.clone().unwrap_or("/".to_owned()),
|
||||
login: config.username.clone(),
|
||||
password: config.password.clone(),
|
||||
scheme: scheme,
|
||||
|
|
Loading…
Reference in a new issue