Fix PR comments

This commit is contained in:
Al Liu 2023-11-12 20:48:22 +08:00
parent e24e0a357b
commit a857823099
No known key found for this signature in database
GPG Key ID: C8AE9A6E0166923E
4 changed files with 9 additions and 24 deletions

View File

@ -65,11 +65,10 @@ where
async fn run(mut self) -> Result<(), ServiceError> {
let endpoint = B::new(self.settings.backend_settings)
.await
.map_err(|e| Box::new(e) as DynError)?;
.map_err(ServiceError::service)?;
endpoint
.serve(self.handle)
.await
.map_err(|e| Box::new(e) as DynError)?;
Ok(())
.map_err(ServiceError::service)
}
}

View File

@ -131,7 +131,7 @@ where
backend,
inbound_relay,
})
.map_err(|e| ServiceError::Service(Box::new(e)))
.map_err(ServiceError::service)
}
async fn run(mut self) -> Result<(), ServiceError> {
@ -195,25 +195,12 @@ where
oneshot::Sender<async_graphql::Response>,
) -> Result<M, ServiceError>,
{
#[derive(Debug)]
struct EmptyPayload;
impl core::fmt::Display for EmptyPayload {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "empty payload")
}
}
impl Error for EmptyPayload {}
let payload = payload
.ok_or(EmptyPayload)
.map_err(|e| ServiceError::Service(Box::new(e)))?;
let payload = payload.ok_or(ServiceError::custom("empty payload"))?;
let req = async_graphql::http::receive_batch_json(&payload[..])
.await
.map_err(|e| ServiceError::Service(Box::new(e)))?
.map_err(ServiceError::service)?
.into_single()
.map_err(|e| ServiceError::Service(Box::new(e)))?;
.map_err(ServiceError::service)?;
let (sender, receiver) = oneshot::channel();
relay
@ -226,6 +213,6 @@ where
.map_err(|e| ServiceError::RelayError(e.0))?;
let res = receiver.await.unwrap();
let res = serde_json::to_string(&res).map_err(|e| ServiceError::Service(Box::new(e)))?;
let res = serde_json::to_string(&res).map_err(ServiceError::service)?;
Ok(res)
}

View File

@ -276,7 +276,7 @@ impl<Backend: StorageBackend + Send + Sync + 'static> ServiceCore for StorageSer
fn init(service_state: ServiceStateHandle<Self>) -> Result<Self, ServiceError> {
Ok(Self {
backend: Backend::new(service_state.settings_reader.get_updated_settings())
.map_err(|e| ServiceError::Service(Box::new(e)))?,
.map_err(ServiceError::service)?,
service_state,
})
}

View File

@ -53,8 +53,7 @@ impl ServiceCore for SystemSig {
async fn run(self) -> Result<(), ServiceError> {
let Self { service_state } = self;
let mut ctrlc =
async_ctrlc::CtrlC::new().map_err(|e| ServiceError::Service(Box::new(e)))?;
let mut ctrlc = async_ctrlc::CtrlC::new().map_err(ServiceError::service)?;
let mut lifecycle_stream = service_state.lifecycle_handle.message_stream();
loop {
tokio::select! {