Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3358404
D13603.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13603.diff
View Options
diff --git a/services/tunnelbroker/src/amqp.rs b/services/tunnelbroker/src/amqp.rs
--- a/services/tunnelbroker/src/amqp.rs
+++ b/services/tunnelbroker/src/amqp.rs
@@ -4,7 +4,7 @@
use std::sync::Arc;
use std::time::Duration;
use tokio::sync::RwLock;
-use tracing::{debug, error, info};
+use tracing::{debug, error, info, warn};
use crate::constants::error_types;
use crate::CONFIG;
@@ -110,6 +110,25 @@
Ok(Self { inner })
}
+ pub async fn new_channel(&self) -> Result<lapin::Channel, lapin::Error> {
+ if !self.is_connected().await {
+ warn!("AMQP disconnected while retrieving channel");
+ self.reset_conn().await?;
+ }
+ self.inner.read().await.conn.create_channel().await
+ }
+
+ async fn reset_conn(&self) -> Result<(), lapin::Error> {
+ let mut inner = self.inner.write().await;
+ if !inner.is_connected() {
+ debug!("Resetting AMQP connection...");
+ let new_conn = ConnectionInner::new().await?;
+ *inner = new_conn;
+ info!("AMQP Connection restored.");
+ }
+ Ok(())
+ }
+
async fn is_connected(&self) -> bool {
self.inner.read().await.is_connected()
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 4:41 AM (22 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578368
Default Alt Text
D13603.diff (1 KB)
Attached To
Mode
D13603: [tunnelbroker] Implement AMQP reconnect on channel access
Attached
Detach File
Event Timeline
Log In to Comment