Skip to content

RPC Rust Runtime #183

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

Merged
merged 109 commits into from
Mar 24, 2022
Merged

RPC Rust Runtime #183

merged 109 commits into from
Mar 24, 2022

Conversation

mattiekat
Copy link
Contributor

No description provided.

@andrewmd5 andrewmd5 linked an issue Mar 10, 2022 that may be closed by this pull request
Copy link

@emily33901 emily33901 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust code looks good to me. Not as familiar with the C# code but I don't see anything glaringly wrong.

@andrewmd5
Copy link
Contributor

I think this needs to be rebased into a feature branch. I know we discussed it briefly but i’d like to avoid massive changes like this going into master until it’s ready across the board.

Copy link
Contributor

@lynn lynn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! I only have some kinda nitpicky comments, but it really LGTM. Awesome job 🚀

Comment on lines +62 to +68
/// Define a timeout value for RPC.
/// This creates an Option<Duration> value which is what RPC requests expect.
///
/// Use as `timeout!(n u)` where `n` is a numeric and `u` is the unit. Example `timeout!(4 s)`
/// creates a 4 second timeout. `timeout!(None)` defines no timeout.
#[macro_export]
macro_rules! timeout {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this macro, and making people write Some(Duration::from_secs(4)) is okay and probably more idiomatic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I think we should keep it is because writing

let resp = router.remote_call(Some(Duration::from_secs(4)), arg1, arg2).await;

is both more verbose making it less likely someone will bother to follow best practice, and also is less easy to read than

let resp = router.remote_call(timeout!(4 s), arg1, arg2).await;

pub fn convert_timeout(timeout: Option<Duration>) -> Option<NonZeroU16> {
timeout.and_then(|t| {
let t = t.as_secs();
debug_assert!(t < u16::MAX as u64, "Maximum timeout is 2^16-1 seconds.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a user-facing error rather than just an assertion? A user might not know about this restriction and define an RPC with a large timeout, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? I was thinking it would usually be something they write into the code so it would be a code bug.

Comment on lines +86 to +89
/// **Warning:** always store weak references or the router will have issues shutting down due
/// to cyclical dependencies.
#[doc(hidden)]
pub _context: Arc<RouterContext>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not change the type to Weak<RouterContext> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is the only owner.

@lynn
Copy link
Contributor

lynn commented Mar 24, 2022

Siding with @andrewmd5 I think making an rpc branch off master and then merging this into that is a good idea.

@mattiekat mattiekat changed the base branch from master to rpc March 24, 2022 20:51
@mattiekat mattiekat merged commit e8a2311 into rpc Mar 24, 2022
@mattiekat mattiekat deleted the rpc-rust-runtime branch March 24, 2022 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPC Proposal Service names should be unique identifiers
4 participants