From 99c9363fafc1dde9764778473f37fc1fa6180d2f Mon Sep 17 00:00:00 2001 From: Piotr Gankiewicz Date: Mon, 1 Jul 2024 08:14:59 +0200 Subject: [PATCH] Allow connecting by hostname (#1019) --- Cargo.lock | 2 +- sdk/Cargo.toml | 2 +- sdk/src/tcp/client.rs | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7b3ef0ed..aaaf28366 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2145,7 +2145,7 @@ dependencies = [ [[package]] name = "iggy" -version = "0.4.3" +version = "0.4.4" dependencies = [ "aes-gcm", "anyhow", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index a7c87dbc1..8d215f05f 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iggy" -version = "0.4.3" +version = "0.4.4" description = "Iggy is the persistent message streaming platform written in Rust, supporting QUIC, TCP and HTTP transport protocols, capable of processing millions of messages per second." edition = "2021" license = "MIT" diff --git a/sdk/src/tcp/client.rs b/sdk/src/tcp/client.rs index 1dd10d1bb..bc1d68a28 100644 --- a/sdk/src/tcp/client.rs +++ b/sdk/src/tcp/client.rs @@ -6,7 +6,6 @@ use crate::tcp::config::TcpClientConfig; use async_trait::async_trait; use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::fmt::Debug; -use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; use tokio::io::{AsyncReadExt, AsyncWriteExt, BufReader, BufWriter}; @@ -26,7 +25,6 @@ const NAME: &str = "Iggy"; /// It requires a valid server address. #[derive(Debug)] pub struct TcpClient { - pub(crate) server_address: SocketAddr, pub(crate) stream: Mutex>>, pub(crate) config: Arc, pub(crate) state: Mutex, @@ -196,11 +194,8 @@ impl TcpClient { /// Create a new TCP client based on the provided configuration. pub fn create(config: Arc) -> Result { - let server_address = config.server_address.parse::()?; - Ok(Self { config, - server_address, stream: Mutex::new(None), state: Mutex::new(ClientState::Disconnected), }) @@ -276,7 +271,7 @@ impl TcpClient { NAME, self.config.server_address ); - let connection = TcpStream::connect(self.server_address).await; + let connection = TcpStream::connect(&self.config.server_address).await; if connection.is_err() { error!( "Failed to connect to server: {}",