Skip to content

Commit bec96f4

Browse files
committed
editoast: share the response tracker dashmap
Signed-off-by: Younes Khoudli <[email protected]>
1 parent 6782d24 commit bec96f4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

editoast/core_client/src/mq_client.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ pub struct RabbitMQClient {
4242
pub struct ChannelManager {
4343
connection: Arc<RwLock<Option<Connection>>>,
4444
hostname: String,
45+
response_tracker: Arc<DashMap<String, oneshot::Sender<Delivery>>>,
4546
}
4647

4748
impl ChannelManager {
4849
pub fn new(connection: Arc<RwLock<Option<Connection>>>, hostname: String) -> Self {
4950
ChannelManager {
5051
connection,
5152
hostname,
53+
response_tracker: Arc::new(DashMap::new()),
5254
}
5355
}
5456
}
@@ -71,7 +73,12 @@ impl Manager for ChannelManager {
7173
.await
7274
.map_err(|_| ChannelManagerError::Lapin)?;
7375

74-
Ok(ChannelWorker::new(Arc::new(channel), self.hostname.clone()).await)
76+
Ok(ChannelWorker::new(
77+
Arc::new(channel),
78+
self.hostname.clone(),
79+
self.response_tracker.clone(),
80+
)
81+
.await)
7582
} else {
7683
Err(ChannelManagerError::ConnectionNotFound)
7784
}
@@ -98,10 +105,14 @@ pub struct ChannelWorker {
98105
}
99106

100107
impl ChannelWorker {
101-
pub async fn new(channel: Arc<Channel>, hostname: String) -> Self {
108+
pub async fn new(
109+
channel: Arc<Channel>,
110+
hostname: String,
111+
response_tracker: Arc<DashMap<String, oneshot::Sender<Delivery>>>,
112+
) -> Self {
102113
let worker = ChannelWorker {
103114
channel,
104-
response_tracker: Arc::new(DashMap::new()),
115+
response_tracker,
105116
consumer_tag: format!("{}-{}", hostname, Uuid::new_v4()),
106117
};
107118
worker.dispatching_loop().await;

0 commit comments

Comments
 (0)