Skip to content

Commit

Permalink
connection_properties: add config to recover on channel failure
Browse files Browse the repository at this point in the history
Experimental, and currently does nothing

Signed-off-by: Marc-Antoine Perennou <[email protected]>
  • Loading branch information
Keruspe committed Jul 27, 2024
1 parent f11b069 commit 69b4c2a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/connection_properties.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
experimental::RecoveryConfig,
reactor::FullReactor,
types::{AMQPValue, FieldTable, LongString},
Error, Result,
Expand All @@ -12,6 +13,7 @@ pub struct ConnectionProperties {
pub client_properties: FieldTable,
pub executor: Option<Arc<dyn FullExecutor + Send + Sync>>,
pub reactor: Option<Arc<dyn FullReactor + Send + Sync>>,
pub recovery_config: Option<RecoveryConfig>,
}

impl Default for ConnectionProperties {
Expand All @@ -21,6 +23,7 @@ impl Default for ConnectionProperties {
client_properties: FieldTable::default(),
executor: None,
reactor: None,
recovery_config: None,
}
}
}
Expand All @@ -47,6 +50,12 @@ impl ConnectionProperties {
self
}

#[must_use]
pub fn with_experimental_recovery_config(mut self, config: RecoveryConfig) -> Self {
self.recovery_config = Some(config);
self
}

pub(crate) fn take_executor(&mut self) -> Result<Arc<dyn FullExecutor + Send + Sync>> {
if let Some(executor) = self.executor.take() {
return Ok(executor);
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};
use amq_protocol::{
frame::{GenError, ParserError, ProtocolVersion},
protocol::{AMQPErrorKind, AMQPSoftError},
protocol::AMQPErrorKind,
};
use std::{error, fmt, io, sync::Arc};

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ pub mod publisher_confirm;
pub mod socket_state;
pub mod topology;

pub mod experimental {
pub use crate::recovery_config::RecoveryConfig;
}

use promise::{Promise, PromiseResolver};

mod acknowledgement;
Expand Down Expand Up @@ -156,6 +160,7 @@ mod parsing;
mod promise;
mod queue;
mod reactor;
mod recovery_config;
mod registry;
mod returned_messages;
mod thread;
Expand Down
4 changes: 4 additions & 0 deletions src/recovery_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[derive(Default, Clone)]
pub struct RecoveryConfig {
pub auto_recover_channels: bool,
}

0 comments on commit 69b4c2a

Please sign in to comment.