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