-
Notifications
You must be signed in to change notification settings - Fork 18
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
cuprated: initial RPC module skeleton #262
Conversation
rpc/interface/src/rpc_error.rs
Outdated
#[derive(Debug, thiserror::Error)] | ||
pub enum RpcError { | ||
/// A [`std::io::Error`] from the database. | ||
#[error("database I/O error: {0}")] | ||
DatabaseIo(#[from] std::io::Error), | ||
|
||
/// A (non-I/O related) database error. | ||
#[error("database error: {0}")] | ||
DatabaseError(RuntimeError), | ||
} |
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.
Change to cuprate_rpc_interface::RpcError
. The database(s) return RuntimeError
in their Service
signatures so we forward that.
This also means that cuprate_rpc_interface
depends on cuprate_database
, it doesn't seem ideal to pull all of it in for just the error type though, especially since none of the errors other than IO can happen at this level.
cuprated
already pulls everything in anyway, but this means other RpcHandler
impls will have to pull in cuprate-database
too.
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.
Would it worth just making this a BoxError
? that's what I have done elsewhere, like in the consensus crate.
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.
If we're going to be (ab)using opaque errors internally, what about using anyhow::Error
?
It's basically a better Box<dyn Error + Send + Sync + 'static>
.
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.
Yeah sure that's probably a good idea.
rpc/interface/src/rpc_error.rs
Outdated
#[derive(Debug, thiserror::Error)] | ||
pub enum RpcError { | ||
/// A [`std::io::Error`] from the database. | ||
#[error("database I/O error: {0}")] | ||
DatabaseIo(#[from] std::io::Error), | ||
|
||
/// A (non-I/O related) database error. | ||
#[error("database error: {0}")] | ||
DatabaseError(RuntimeError), | ||
} |
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.
Would it worth just making this a BoxError
? that's what I have done elsewhere, like in the consensus crate.
What
Adds the initial skeleton for the RPC module in
cuprated
and many function signatures filled withtodo!()
.