coupled socket shutdown with epp logout

This commit is contained in:
Ritesh Chitlangi 2021-11-12 00:48:07 +08:00 committed by masalachai
parent e07eba2de2
commit c5e467b023
25 changed files with 31 additions and 34 deletions

View File

@ -96,7 +96,7 @@ async fn main() {
.iter() .iter()
.for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available)); .for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available));
client.close().await.unwrap(); client.logout().await.unwrap();
} }
``` ```

View File

@ -13,7 +13,6 @@ repository = "https://github.com/masalachai/epp-client"
epp-client-macros = "0.1" # { path = "../epp-client-macros" } epp-client-macros = "0.1" # { path = "../epp-client-macros" }
bytes = "1" bytes = "1"
chrono = "0.4" chrono = "0.4"
futures = "0.3"
env_logger = "0.9" env_logger = "0.9"
log = "0.4" log = "0.4"
quick-xml = { version = "0.22", features = [ "serialize" ] } quick-xml = { version = "0.22", features = [ "serialize" ] }

View File

@ -184,12 +184,10 @@ impl EppClient {
let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap(); let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap();
let epp_logout = EppLogout::new(client_tr_id.as_str()); let epp_logout = EppLogout::new(client_tr_id.as_str());
self.transact::<_, EppLogoutResponse>(&epp_logout).await let response = self.transact::<_, EppLogoutResponse>(&epp_logout).await?;
}
pub async fn close(&mut self) -> Result<(), error::Error> { self.connection.shutdown().await?;
self.logout().await?;
Ok(self.connection.close().await?) Ok(response)
} }
} }

View File

@ -127,8 +127,8 @@ impl EppConnection {
Ok(response) Ok(response)
} }
/// Closes the socket /// Closes the socket and shuts the connection
pub async fn close(&mut self) -> Result<(), Box<dyn Error>> { pub async fn shutdown(&mut self) -> Result<(), Box<dyn Error>> {
info!("{}: Closing connection", self.registry); info!("{}: Closing connection", self.registry);
self.stream.writer.shutdown().await?; self.stream.writer.shutdown().await?;

View File

@ -52,7 +52,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactCheck = EppObject<Command<ContactCheck>>; pub type EppContactCheck = EppObject<Command<ContactCheck>>;

View File

@ -69,7 +69,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactCreate = EppObject<Command<ContactCreate>>; pub type EppContactCreate = EppObject<Command<ContactCreate>>;

View File

@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactDelete = EppObject<Command<ContactDelete>>; pub type EppContactDelete = EppObject<Command<ContactDelete>>;

View File

@ -55,7 +55,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactInfo = EppObject<Command<ContactInfo>>; pub type EppContactInfo = EppObject<Command<ContactInfo>>;

View File

@ -65,7 +65,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactUpdate = EppObject<Command<ContactUpdate>>; pub type EppContactUpdate = EppObject<Command<ContactUpdate>>;

View File

@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainCheck = EppObject<Command<DomainCheck>>; pub type EppDomainCheck = EppObject<Command<DomainCheck>>;

View File

@ -73,7 +73,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainCreate = EppObject<Command<DomainCreate>>; pub type EppDomainCreate = EppObject<Command<DomainCreate>>;

View File

@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainDelete = EppObject<Command<DomainDelete>>; pub type EppDomainDelete = EppObject<Command<DomainDelete>>;

View File

@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainInfo = EppObject<Command<DomainInfo>>; pub type EppDomainInfo = EppObject<Command<DomainInfo>>;

View File

@ -57,7 +57,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainRenew = EppObject<Command<DomainRenew>>; pub type EppDomainRenew = EppObject<Command<DomainRenew>>;

View File

@ -80,7 +80,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainRgpRestoreReport = pub type EppDomainRgpRestoreReport =

View File

@ -57,7 +57,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainRgpRestoreRequest = pub type EppDomainRgpRestoreRequest =

View File

@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferRequest = EppObject<Command<DomainTransfer>>; pub type EppDomainTransferRequest = EppObject<Command<DomainTransfer>>;
@ -103,7 +103,7 @@ pub type EppDomainTransferRequest = EppObject<Command<DomainTransfer>>;
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferApprove = EppObject<Command<DomainTransfer>>; pub type EppDomainTransferApprove = EppObject<Command<DomainTransfer>>;
@ -153,7 +153,7 @@ pub type EppDomainTransferApprove = EppObject<Command<DomainTransfer>>;
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferReject = EppObject<Command<DomainTransfer>>; pub type EppDomainTransferReject = EppObject<Command<DomainTransfer>>;
@ -203,7 +203,7 @@ pub type EppDomainTransferReject = EppObject<Command<DomainTransfer>>;
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferCancel = EppObject<Command<DomainTransfer>>; pub type EppDomainTransferCancel = EppObject<Command<DomainTransfer>>;
@ -253,7 +253,7 @@ pub type EppDomainTransferCancel = EppObject<Command<DomainTransfer>>;
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferQuery = EppObject<Command<DomainTransfer>>; pub type EppDomainTransferQuery = EppObject<Command<DomainTransfer>>;

View File

@ -77,7 +77,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainUpdate = EppObject<Command<DomainUpdate<HostObjList>>>; pub type EppDomainUpdate = EppObject<Command<DomainUpdate<HostObjList>>>;

View File

@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostCheck = EppObject<Command<HostCheck>>; pub type EppHostCheck = EppObject<Command<HostCheck>>;

View File

@ -58,7 +58,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostCreate = EppObject<Command<HostCreate>>; pub type EppHostCreate = EppObject<Command<HostCreate>>;

View File

@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostDelete = EppObject<Command<HostDelete>>; pub type EppHostDelete = EppObject<Command<HostDelete>>;

View File

@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostInfo = EppObject<Command<HostInfo>>; pub type EppHostInfo = EppObject<Command<HostInfo>>;

View File

@ -74,7 +74,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostUpdate = EppObject<Command<HostUpdate>>; pub type EppHostUpdate = EppObject<Command<HostUpdate>>;

View File

@ -48,7 +48,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppMessageAck = EppObject<Command<MessageAck>>; pub type EppMessageAck = EppObject<Command<MessageAck>>;

View File

@ -49,7 +49,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.close().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppMessagePoll = EppObject<Command<MessagePoll>>; pub type EppMessagePoll = EppObject<Command<MessagePoll>>;