Skip to content

Commit

Permalink
pass in host name to updated stubborn io
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Nov 18, 2023
1 parent 7e6a6d2 commit 232a041
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rust/libraries/acars_connection_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
stubborn-io = "0.3.2"
stubborn-io = { git = "https://github.com/sdr-enthusiasts/sdre-stubborn-io.git" }
log = "0.4.20"
tokio = { version = "1.34.0", features = ["full", "tracing"] }
tokio-util = { version = "0.7.10", features = ["full"] }
Expand Down
3 changes: 2 additions & 1 deletion rust/libraries/acars_connection_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ pub(crate) struct OutputServerConfig {
// to attempt to reconnect
// See: https://docs.rs/stubborn-io/latest/src/stubborn_io/config.rs.html#93

pub fn reconnect_options() -> ReconnectOptions {
pub fn reconnect_options(host: &str) -> ReconnectOptions {
ReconnectOptions::new()
.with_exit_if_first_connect_fails(false)
.with_retries_generator(get_our_standard_reconnect_strategy)
.with_connection_name(host)
}

fn get_our_standard_reconnect_strategy() -> DurationIterator {
Expand Down
5 changes: 3 additions & 2 deletions rust/libraries/acars_connection_manager/src/service_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ impl SenderServers for Arc<Mutex<Vec<Sender<AcarsVdlm2Message>>>> {
async fn start_tcp(self, socket_type: &str, host: &str) {
// Start a TCP sender server for {server_type}
let socket: Result<StubbornIo<TcpStream, String>, io::Error> =
StubbornTcpStream::connect_with_options(host.to_string(), reconnect_options()).await;
StubbornTcpStream::connect_with_options(host.to_string(), reconnect_options(host))
.await;
match socket {
Err(e) => error!("[TCP SENDER {socket_type}]: Error connecting to {host}: {e}"),
Ok(socket) => {
Expand Down Expand Up @@ -537,7 +538,7 @@ impl SocketListenerServer {
let open_stream: io::Result<StubbornIo<TcpStream, SocketAddr>> =
StubbornTcpStream::connect_with_options(
socket_address,
reconnect_options(),
reconnect_options(&self.proto_name),
)
.await;
match open_stream {
Expand Down
6 changes: 5 additions & 1 deletion rust/libraries/acars_connection_manager/src/tcp_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ impl TCPReceiverServer {
}
};

let stream = match StubbornTcpStream::connect_with_options(addr, reconnect_options()).await
let stream = match StubbornTcpStream::connect_with_options(
addr,
reconnect_options(&self.proto_name),
)
.await
{
Ok(stream) => stream,
Err(e) => {
Expand Down

0 comments on commit 232a041

Please sign in to comment.