-
Notifications
You must be signed in to change notification settings - Fork 98
Add support for protocol version Bilrost (v2) #3190
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
Conversation
e2d0499
to
c3fc171
Compare
967bce7
to
be41686
Compare
@muhamadazmy I've removed myself as reviewer, feel free to add me back when this is ready for review. |
3edffff
to
248eddd
Compare
9cbe49d
to
74d1e48
Compare
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.
Very good work @mohammedazmy. I like how clear it's to follow the design.
crates/encoding/derive/Cargo.toml
Outdated
@@ -0,0 +1,17 @@ | |||
[package] | |||
name = "encoding-derive" |
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.
name = "encoding-derive" | |
name = "restate-encoding-derive" |
crates/encoding/src/lib.rs
Outdated
|
||
impl<T> NetSerde for Vec<T> where T: NetSerde {} | ||
impl<T> NetSerde for Option<T> where T: NetSerde {} | ||
impl<K, V> NetSerde for HashMap<K, V> |
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.
You might need to add S
as a third parameter here to cover all hashmap types.
@@ -16,6 +16,7 @@ use bytes::Bytes; | |||
use serde::Serialize; | |||
use serde::de::DeserializeOwned; | |||
|
|||
use super::{FromBilrostDto, IntoBilrostDto}; | |||
use crate::protobuf::common::ProtocolVersion; | |||
|
|||
pub trait WireEncode { |
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.
I wonder if we should make WireEncode be bound to NetSerde types, that would be cool. Can happen in follow-up PRs.
Also introduce two new derive macros: - `BilrostNewType` to use with all ID types or any tuple with a single item. This will effectively flatten this tuple to its inner type. Given that the inner field is bilrost serializable - `NetworkMessage` which must be derived for each message that is going to be send over the network
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.
Some minor comments that I stumbled upon.
/// allowing them to be stored or transferred directly without transformation. | ||
/// | ||
pub trait FromBilrostDto: Sized { | ||
type Target: bilrost::OwnedMessage + NetSerde; |
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.
Should this be Source
instead of Target
?
impl $crate::net::IntoBilrostDto for $message { | ||
type Target = $as_type; | ||
|
||
fn into_dto(self) -> $as_type { | ||
self.into() | ||
} | ||
} | ||
|
||
impl $crate::net::FromBilrostDto for $message { | ||
type Target = $as_type; | ||
type Error = <$message as TryFrom<$as_type>>::Error; | ||
|
||
fn from_dto(value: Self::Target) -> Result<Self, Self::Error> { | ||
value.try_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.
I think we should mention the TryFrom
and Into
requirements fro the $as_type
. This is not clear from the docs of the macro.
#[proc_macro_derive(BilrostNewType)] | ||
pub fn bilrost_new_type(item: TokenStream) -> TokenStream { | ||
bilrost::new_type(item) | ||
} |
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.
Some minimal for when and how to use this macro could be helpful.
Add support for protocol version Bilrost (v2)
Also introduce two new derive macros:
BilrostNewType
to use with all ID types or any tuple with a single item. This willeffectively flatten this tuple to its inner type. Given that the inner field is bilrost serializable
NetworkMessage
which must be derived for each message that is going to be send over the networkStack created with Sapling. Best reviewed with ReviewStack.