Offer API to reconnect an EppClient
This commit is contained in:
parent
8cad81ab3d
commit
c9f9ea1fea
|
@ -148,6 +148,10 @@ impl<C: Connector> EppClient<C> {
|
|||
GreetingDocument::deserialize(&self.connection.greeting).map(|obj| obj.data)
|
||||
}
|
||||
|
||||
pub async fn reconnect(&mut self) -> Result<(), Error> {
|
||||
self.connection.reconnect().await
|
||||
}
|
||||
|
||||
pub async fn shutdown(mut self) -> Result<(), Error> {
|
||||
self.connection.shutdown().await
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use crate::error::Error;
|
|||
/// EPP Connection struct with some metadata for the connection
|
||||
pub(crate) struct EppConnection<C: Connector> {
|
||||
registry: String,
|
||||
connector: C,
|
||||
stream: C::Connection,
|
||||
pub greeting: String,
|
||||
timeout: Duration,
|
||||
|
@ -28,6 +29,7 @@ impl<C: Connector> EppConnection<C> {
|
|||
let mut this = Self {
|
||||
registry,
|
||||
stream: connector.connect(timeout).await?,
|
||||
connector,
|
||||
greeting: String::new(),
|
||||
timeout,
|
||||
};
|
||||
|
@ -88,6 +90,12 @@ impl<C: Connector> EppConnection<C> {
|
|||
Ok(String::from_utf8(buf)?)
|
||||
}
|
||||
|
||||
pub(crate) async fn reconnect(&mut self) -> Result<(), Error> {
|
||||
self.stream = self.connector.connect(self.timeout).await?;
|
||||
self.greeting = self.get_epp_response().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sends an EPP XML request to the registry and return the response
|
||||
/// receieved to the request
|
||||
pub(crate) async fn transact(&mut self, content: &str) -> Result<String, Error> {
|
||||
|
|
Loading…
Reference in New Issue