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

Update UListener interface and UUID builder #24

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

evshary
Copy link
Contributor

@evshary evshary commented Apr 10, 2024

The PR is to update up-rust to the latest version, including the following changes:

Signed-off-by: ChenYing Kuo <[email protected]>
@evshary
Copy link
Contributor Author

evshary commented Apr 10, 2024

@AnotherDaniel and @PLeVasseur I'm still fixing the tests in the PR, but you can take a look if you need this.

@evshary evshary marked this pull request as ready for review April 11, 2024 08:33
Signed-off-by: ChenYing Kuo <[email protected]>
@evshary
Copy link
Contributor Author

evshary commented Apr 11, 2024

@AnotherDaniel and @PLeVasseur You can review the PR now. Since Daniel wants this urgently, I'll deal with some minor issues in another PR.

}
};
resp_callback(msg);
}
};

// Send query
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not great at Zenoh :)

I'm trying to understand if there's any issue with us using the zenoh_key here alone. Is it possible that if we fired off two requests, one after the other that we'd end up getting them back in the wrong order? Should we make use of the req_id at all?

Sorry for newb questions 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Zenoh will take care of the order of queries and not mix them. That's why we don't need to use req_id while sending the query.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain a little detail behind how the queries are ordered correctly?

If we sent out two Request messages one immediately after the other, call them A and B. And a Response messages was sent back for B first, how does the ordering get enforced?

If there's some bit of documentation or better yet code / tests that show this I think that'd be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each time we create a Zenoh query to send out, there is also a qid inside Zenoh, which is used to differentiate different messages. While receiving the response message, Zenoh will use the qid to find the corresponding buffer to put the message.

In your case, we called invoke_method(A) and invoke_method(B). invoke_method(A) should only get the response message from its buffer with the correct qid. Response message to B will never go inside the buffer of A.

Since this is the mechanism inside Zenoh, I prefer to hide it instead of exposing to users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh okay. So even though the zenoh_key may be the same, there's the qid in the implementation of Zenoh that will correctly tie together each request with the corresponding response. Makes sense.


Maybe not on this PR, but I think it'd be nice to show executing a couple of invoke_method() one after the other and showing they come back in the correct order. Ensuring in the test that we invoke_method() on another task so we can immediately call it again and show that even though we fired request_A, _request_B and were returned response_B, response_A they were correlated correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we should make sure the callback won't block while accepting the first request.
Maybe related to the issue

Choose a reason for hiding this comment

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

@evshary there will be an issue if you do not pass reqid in the zenoh message we will have issues correlating a message across transports. Is the reqid passed in the UMessage returned from the transport??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reqid is still passed in UAttributes (in UMessage). It's just not used in Zenoh mechansim.

Copy link
Contributor

Choose a reason for hiding this comment

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

@stevenhartley -- as we chatted about offline, I think the handling is done correctly in the Request / Response flow, even in usage by the UStreamer, based on my current understanding.

@evshary -- can you confirm if this diagram accurately represents usage of up-client-zenoh-rust?

sequenceDiagram
    participant ue as uE
    participant ue_z as up-client-zenoh-rust
    participant st_z as up-client-zenoh-rust
    participant st as up-streamer-rust
    participant st_s as up-client-someip-rust
    participant me_s as up-client-someip-rust
    participant me as mE

ue->>ue_z: register_listener<br>(my_uuri, my_listener)
ue_z->>ue_z: register_response_listener()

me->>me_s: register_listener<br>(service_uuri, service_listener)
me_s->>me_s: registering

st->>st_z: register_listener<br>(zenoh_auth_uuri,<br> forwarding_listener)
st_z->>st_z: register_publish_notification_listener()
st_z->>st_z: register_request_listener() <br> (Zenoh callback puts <br> request_msg.attributes.id <br> into a HashMap<reqid, Zenoh Query>)
st_z->>st_z: register_response_listener()

st->>st_s: register_listener<br>(someip_auth_uuri,<br> forwarding_listener)
st_s->>st_s: registering

ue->>ue_z: send(request_msg)
ue_z->>ue_z: send_request(request_msg)
ue_z->>st_z: Zenoh Queryable

st_z->>st_z: Zenoh Callback for zenoh_auth_uuri <br> (which inserts request_msg.attributes.id <br> into query_map)
st_z->>st_z: on_receive(request_msg)
st_z->>st: send request_msg <br> to TransportForwarder
st->>st_s: send(request_msg)

st_s->>me_s: SOME/IP
me_s->>me_s: on_receive(request_msg)
me_s->>me: react to request_msg

me->>me: process request_msg
me->>me: create response_msg
me->>me_s: send(response_msg)

me_s->>st_s: SOME/IP
st_s->>st_s: on_receive(response_msg)
st_s->>st: send response_msg <br> to TransportForwarder
st->>st_z: send(response_msg)
st_z->>st_z: send_response(response_msg) <br> (Extracts response_msg.attributes.reqid <br> and will look up the stored Zenoh Query)

st_z->>ue_z: Zenoh Reply
ue_z->>ue_z: on_receive(response_msg)
ue_z->>ue: react to response_msg
Loading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PLeVasseur Good diagram! I think this is correct.

src/rpc.rs Show resolved Hide resolved
src/rpc.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@PLeVasseur
Copy link
Contributor

PLeVasseur commented Apr 16, 2024

Hey @evshary -- was this addressed in this PR? Will be done in another?

Could you point me to where you'd need to update? Maybe this?

tests/publish.rs Outdated Show resolved Hide resolved
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.

LGTM! Thanks for the updates @evshary 🙂

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.

3 participants