Skip to content

Commit

Permalink
remote store gRPC spec update: introduce application level errors for…
Browse files Browse the repository at this point in the history
… registration response (#7904)

### What

Introduce registration application level error. It will still be leveraged as a gRPC error (as all register_recording() call failure can simply be gRPC errors), but it ensures we have proper structure for the gRPC Status details.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7904?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7904?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7904)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
zehiko authored Oct 25, 2024
1 parent abb2b77 commit a825454
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/store/re_remote_store_types/proto/rerun/v0/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,15 @@ enum SparseFillStrategy {
NONE = 0;
LATEST_AT_GLOBAL = 1;
}

// Error codes for application level errors
enum ErrorCode {
// unused
_UNUSED = 0;

// object store access error
OBJECT_STORE_ERROR = 1;

// metadata database access error
METADATA_DB_ERROR = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ message RegisterRecordingsResponse {
repeated RecordingMetadata metadata = 2;
}

// Server can include details about the error as part of gRPC error (Status)
message RegistrationError {
// error code
ErrorCode code = 1;
// url of the recording that failed to register
string url = 2;
// human readable details about the error
string message = 3;
}

// ---------------- GetRecordingMetadata -----------------

message GetRecordingMetadataRequest {
Expand Down
12 changes: 12 additions & 0 deletions crates/store/re_remote_store_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ pub mod v0 {
}
}
}

// ------- Application level errors -------
impl std::error::Error for RegistrationError {}

impl std::fmt::Display for RegistrationError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"Failed to register recording: {}, error code: {}, error message: {}",
self.url, self.code, self.message
))
}
}
}

#[cfg(test)]
Expand Down
46 changes: 46 additions & 0 deletions crates/store/re_remote_store_types/src/v0/rerun.remote_store.v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,39 @@ impl SparseFillStrategy {
}
}
}
/// Error codes for application level errors
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ErrorCode {
/// unused
Unused = 0,
/// object store access error
ObjectStoreError = 1,
/// metadata database access error
MetadataDbError = 2,
}
impl ErrorCode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unused => "_UNUSED",
Self::ObjectStoreError => "OBJECT_STORE_ERROR",
Self::MetadataDbError => "METADATA_DB_ERROR",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"_UNUSED" => Some(Self::Unused),
"OBJECT_STORE_ERROR" => Some(Self::ObjectStoreError),
"METADATA_DB_ERROR" => Some(Self::MetadataDbError),
_ => None,
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterRecordingsRequest {
#[prost(string, tag = "1")]
Expand All @@ -235,6 +268,19 @@ pub struct RegisterRecordingsResponse {
#[prost(message, repeated, tag = "2")]
pub metadata: ::prost::alloc::vec::Vec<RecordingMetadata>,
}
/// Server can include details about the error as part of gRPC error (Status)
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegistrationError {
/// error code
#[prost(enumeration = "ErrorCode", tag = "1")]
pub code: i32,
/// url of the recording that failed to register
#[prost(string, tag = "2")]
pub url: ::prost::alloc::string::String,
/// human readable details about the error
#[prost(string, tag = "3")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRecordingMetadataRequest {
#[prost(message, optional, tag = "1")]
Expand Down

0 comments on commit a825454

Please sign in to comment.