-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Stream fence
and trim
commands
#46
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ pub enum S2CliError { | |
Service(#[from] ServiceError), | ||
} | ||
|
||
#[derive(Debug)] | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum ServiceErrorContext { | ||
ListBasins, | ||
CreateBasin, | ||
|
@@ -63,6 +63,8 @@ pub enum ServiceErrorContext { | |
DeleteStream, | ||
GetStreamConfig, | ||
CheckTail, | ||
Trim, | ||
Fence, | ||
AppendSession, | ||
ReadSession, | ||
ReconfigureStream, | ||
|
@@ -81,6 +83,8 @@ impl std::fmt::Display for ServiceErrorContext { | |
ServiceErrorContext::DeleteStream => write!(f, "Failed to delete stream"), | ||
ServiceErrorContext::GetStreamConfig => write!(f, "Failed to get stream config"), | ||
ServiceErrorContext::CheckTail => write!(f, "Failed to check tail"), | ||
ServiceErrorContext::Trim => write!(f, "Failed to trim"), | ||
ServiceErrorContext::Fence => write!(f, "Failed to set fencing token"), | ||
ServiceErrorContext::AppendSession => write!(f, "Failed to append session"), | ||
ServiceErrorContext::ReadSession => write!(f, "Failed to read session"), | ||
ServiceErrorContext::ReconfigureStream => write!(f, "Failed to reconfigure stream"), | ||
|
@@ -90,7 +94,7 @@ impl std::fmt::Display for ServiceErrorContext { | |
|
||
/// Error for holding relevant info from `tonic::Status` | ||
#[derive(thiserror::Error, Debug, Default)] | ||
#[error("{status}: \n{message}")] | ||
#[error("{status}:\n {message}")] | ||
pub struct ServiceStatus { | ||
pub message: String, | ||
pub status: String, | ||
|
@@ -103,25 +107,25 @@ impl From<ClientError> for ServiceStatus { | |
message: status.message().to_string(), | ||
status: status.code().to_string(), | ||
}, | ||
_ => Self { | ||
message: error.to_string(), | ||
..Default::default() | ||
ClientError::Conversion(conv) => Self { | ||
message: conv.to_string(), | ||
status: "Failed to convert SDK type".to_string(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I meant to also include the underlying message There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh doh, my original complaint is not valid ;P |
||
}, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
#[error("{kind}:\n {status}")] | ||
#[error("{context}:\n {status}")] | ||
pub struct ServiceError { | ||
kind: ServiceErrorContext, | ||
context: ServiceErrorContext, | ||
status: ServiceStatus, | ||
} | ||
|
||
impl ServiceError { | ||
pub fn new(kind: ServiceErrorContext, status: impl Into<ServiceStatus>) -> Self { | ||
pub fn new(context: ServiceErrorContext, status: impl Into<ServiceStatus>) -> Self { | ||
Self { | ||
kind, | ||
context, | ||
status: status.into(), | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the space there helps look like an inline, does it mess up with the output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The space was in the wrong place, this should fix it :)