2024-09-04 17:20:59 +02:00
|
|
|
pub type RemoteResult<T> = std::result::Result<T, RemoteError>;
|
2024-09-01 02:46:03 +02:00
|
|
|
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
2024-09-04 17:20:59 +02:00
|
|
|
#[error("server rejected procedure with error code: {0}")]
|
|
|
|
pub struct RemoteError(#[from] tonic::Status);
|
2023-09-04 03:08:52 +02:00
|
|
|
|
2023-08-19 21:44:27 +02:00
|
|
|
|
2024-09-01 02:46:03 +02:00
|
|
|
|
|
|
|
pub type ConnectionResult<T> = std::result::Result<T, ConnectionError>;
|
|
|
|
|
2024-08-06 23:00:04 +02:00
|
|
|
#[derive(Debug, thiserror::Error)]
|
2024-09-01 02:46:03 +02:00
|
|
|
pub enum ConnectionError {
|
|
|
|
#[error("network error: {0}")]
|
|
|
|
Transport(#[from] tonic::transport::Error),
|
2023-07-30 17:48:55 +02:00
|
|
|
|
2024-09-01 02:46:03 +02:00
|
|
|
#[error("server rejected connection attempt: {0}")]
|
2024-09-04 17:20:59 +02:00
|
|
|
Remote(#[from] RemoteError),
|
2023-07-30 17:48:55 +02:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:20:59 +02:00
|
|
|
impl From<tonic::Status> for ConnectionError {
|
|
|
|
fn from(value: tonic::Status) -> Self {
|
|
|
|
Self::Remote(RemoteError(value))
|
2023-07-30 17:48:55 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-11 15:34:04 +02:00
|
|
|
|
2023-08-16 18:58:42 +02:00
|
|
|
|
2024-01-25 02:13:45 +01:00
|
|
|
|
2024-09-01 02:46:03 +02:00
|
|
|
pub type ControllerResult<T> = std::result::Result<T, ControllerError>;
|
|
|
|
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
|
|
pub enum ControllerError {
|
|
|
|
#[error("worker is already stopped")]
|
|
|
|
Stopped,
|
|
|
|
|
|
|
|
#[error("worker stopped before completing requested operation")]
|
|
|
|
Unfulfilled,
|
2023-08-16 18:58:42 +02:00
|
|
|
}
|
2023-08-21 02:35:56 +02:00
|
|
|
|
2024-09-01 02:46:03 +02:00
|
|
|
impl<T> From<tokio::sync::mpsc::error::SendError<T>> for ControllerError {
|
|
|
|
fn from(_: tokio::sync::mpsc::error::SendError<T>) -> Self {
|
|
|
|
Self::Stopped
|
2024-08-13 18:00:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-01 02:46:03 +02:00
|
|
|
impl From<tokio::sync::oneshot::error::RecvError> for ControllerError {
|
|
|
|
fn from(_: tokio::sync::oneshot::error::RecvError) -> Self {
|
|
|
|
Self::Unfulfilled
|
2023-08-21 02:35:56 +02:00
|
|
|
}
|
|
|
|
}
|