Skip to content
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

Initial support 1.5.8 #40

Merged
merged 11 commits into from
Jun 14, 2024
Merged

Conversation

evshary
Copy link
Contributor

@evshary evshary commented Jun 3, 2024

The PR is to support up-spec 1.5.8
Close #39

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary evshary marked this pull request as ready for review June 4, 2024 11:08
@evshary evshary linked an issue Jun 4, 2024 that may be closed by this pull request
@evshary
Copy link
Contributor Author

evshary commented Jun 4, 2024

@PLeVasseur Would you mind taking a look?

@PLeVasseur
Copy link
Contributor

Hi @evshary -- I'm on vacation starting tomorrow till next Monday. I'll see if I can sneak a review of this in. :)

@evshary
Copy link
Contributor Author

evshary commented Jun 5, 2024

Hi @evshary -- I'm on vacation starting tomorrow till next Monday. I'll see if I can sneak a review of this in. :)

Hi @PLeVasseur It's fine to be reviewed next week. Enjoy your vacation!

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@@ -31,6 +29,15 @@ use zenoh::{
subscriber::Subscriber,
};

// CY_TODO: Whether to expose from up_rust or not
Copy link
Contributor

Choose a reason for hiding this comment

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

Very good question. IMHO it makes sense for these to live in up-rust.

@@ -277,97 +208,111 @@ impl UPClientZenoh {
};
Ok(uattributes)
}

/* The table for mapping resource ID to message type
Copy link
Contributor

Choose a reason for hiding this comment

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

If this table doesn't exist in up-spec it'd be great to have you contribute to adding it there!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So is the table clear to you? The reason why I hesitate to add the table into spec is that I'm afraid it makes readers difficult to understand.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I get it. I spent a few minutes just mentally going over the table to see if it aligned with my understanding.

I think, even if it takes some time for someone to process what's in the table, it makes a lot more sense to have it written up in a place like up-spec that can be referenced for any implementation 🙂

self.register_request_listener(&topic, listener.clone())
let flag = UPClientZenoh::get_listener_message_type(source_filter, sink_filter)?;
// Publish & Notification
if flag.contains(MessageFlag::Publish) || flag.contains(MessageFlag::Notification) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So I think based on how I am reading this, the intention looks to be that the source and sink filters may result in more than one bit being set in the bitmask enum. That seems to be the intent. And that makes sense.

I'm having a hard time seeing how the function get_listener_message_type() can set multiple bits. It looks like a single value is set based on the if conditionals and returned. Hmm. Perhaps I need to read more 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right... I made the silly mistakes.
I updated how get_listener_message_type works and added more tests case to avoid the mistakes in the future.

#[test_case(test_lib::create_utransport_uuri(Some(0), 0, 0); "Publish / Notification register_listener")]
#[test_case(test_lib::create_rpcserver_uuri(Some(0), 0); "RPC register_listener")]
#[test_case(test_lib::create_special_uuri(0); "Special UUri register_listener")]
#[test_case(&test_lib::new_uuri("src", 1, 1, 0x8000), None; "Listen to Publish")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to listen to all point to point messages? I see ability to listen to all messages of a given type. What about being able to express "all messages with a sink whose source authority_name is foo"?

That's one of the streamer use cases for connecting two authorities together over two transports.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just checked the uP-L1 Zenoh spec. Looks like this case may have been missed. Can we update the spec to clarify this is also possible and add this capability to the transport? (If I am reading it correctly it looks like registering to get all point to point messages as it was in 1.5.7 is not possible in the current implementation. Very possible I'm wrong and if so please point it out 😅)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this what you expect? I added the uStreamer test cases in the tests now.
ea3a993#diff-c19a9c920bb76a5ab06a7d28f16df025d34c3a66697465b9e92c9df37ecdc0a3R36

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 this is pretty close, left a comment on that test.

* - Response: {(0-8000), 0}, {(0-8000), FFFF}, (FFFF, 0), {FFFF, FFFF}
*/
#[allow(clippy::nonminimal_bool)] // Don't simplify the boolean expression for better understanding
fn get_listener_message_type(
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO something very similar could be useful in up-rust with modifications to support the uStreamer case of all point to point messages from a certain authority.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Copy link
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

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

I think you may need to modify or make a new test so that we can test the uStreamer use-case of all of Notification, Request, and Response.

@PLeVasseur
Copy link
Contributor

I think it'd be good to update the name to up-transport-zenoh, too.

@PLeVasseur
Copy link
Contributor

As I start to work with the Zenoh transport, I think it would be good if from this crate we re-exported some key Zenoh items such that an end-user of up-transport-zenoh-rust doesn't also need to pull in Zenoh as a dependency and can use the stuff required from there.

I'm thinking specifically at the moment about Zenoh's Config, as it would appear in order to configure the Zenoh transport I do need to pass in a Config into new().

src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary
Copy link
Contributor Author

evshary commented Jun 13, 2024

I think you may need to modify or make a new test so that we can test the uStreamer use-case of all of Notification, Request, and Response.

I found something wrong with Response use case. In the previous implementation, calling register_listener for Response message doesn't work with a wildcard. It always needs to have the fully-matching Zenoh key. That means the Zenoh key from register_listener and send(request) should be the same.

I fixed the issue with the help of the intersection in Zenoh key. Now register_listener and send(request) don't need to be the same. They can be intersected.

@PLeVasseur Let me know if the test case is not what you imagine.

entity: Some(uentity).into(),
..Default::default()
};
pub async fn new(config: Config, authority_name: String) -> Result<UPClientZenoh, UStatus> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @evshary -- for the uStreamer use-case we'll need a function to build a UPClientZenoh object from a Zenoh Runtime in order to fit within the topology with up-linux-streamer as a Zenoh plugin.

I'm okay if you want to merge this one and address that in a follow up. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Don't make the PR to lengthy. I'll create an issue to track.

@@ -21,8 +21,9 @@ use std::{
};
use tokio::runtime::Runtime;
use up_rust::{ComparableListener, UAttributes, UCode, UListener, UPriority, UStatus, UUri};
// Re-export Zenoh config
pub use zenoh::config::Config;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this enough to configure a Config completely? Or should we re-export all of zenoh::config::*?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like there will be some conflicts if expose all config. I'll deal with it later.

@evshary evshary merged commit b8925c6 into eclipse-uprotocol:main Jun 14, 2024
7 checks passed
@evshary evshary deleted the bump_1.5.8 branch June 14, 2024 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants