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

request_id attribute for generic response #42

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

kyle-tennison
Copy link

Depends on Avarok-Cybersecurity/Citadel-Protocol#218

This allows us to use .request_id on any incoming response, which makes it much easier (and quicker) to access response ids from incoming messages.

Let me know if there is any way I can restructure this.

@kyle-tennison kyle-tennison requested review from Tjemmmic and tbraun96 and removed request for Tjemmmic August 3, 2024 02:33
@kyle-tennison kyle-tennison changed the title ResponseId trait for responses ResponseId attribute for generic response Aug 3, 2024
@kyle-tennison kyle-tennison changed the title ResponseId attribute for generic response response_id attribute for generic response Aug 3, 2024
@kyle-tennison kyle-tennison changed the title response_id attribute for generic response request_id attribute for generic response Aug 3, 2024
Copy link
Contributor

@Tjemmmic Tjemmmic left a comment

Choose a reason for hiding this comment

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

Looks good! Being able to get the request_id for all enum variants is a great feature

}
}

impl InternalServiceResponse {
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 you could use a proc macro to simplify this. Take a look at the answer on this.

@@ -553,6 +555,7 @@ pub struct FileTransferRequestNotification {
pub cid: u64,
pub peer_cid: u64,
pub metadata: VirtualObjectMetadata,
pub request_id: Option<Uuid>,
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there are a few occurrences in tests that didn't get updated to reflect the addition of request_id

@@ -570,6 +573,11 @@ pub struct FileTransferTickNotification {
pub cid: u64,
pub peer_cid: Option<u64>,
pub status: ObjectTransferStatus,
pub request_id: Option<Uuid>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially the same as with the other struct. Take a look at the clippy workflow to see the test it shows an error for.

@@ -368,6 +368,7 @@ fn spawn_tick_updater(
cid: implicated_cid,
peer_cid,
status: status_message,
request_id: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

We would ideally want to make this the same as the request_id as the initial file transfer request that initiated this.

@@ -53,6 +53,7 @@ pub async fn handle<T: IOInterface>(
cid: implicated_cid,
peer_cid,
metadata,
request_id: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -27,7 +27,9 @@ pub trait IOInterfaceExt: IOInterface {
tokio::task::spawn(async move {
let write_task = async move {
let response =
InternalServiceResponse::ServiceConnectionAccepted(ServiceConnectionAccepted);
InternalServiceResponse::ServiceConnectionAccepted(ServiceConnectionAccepted {
request_id: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, this request_id matches that of the initiated connection so we know which request this belongs to

@tbraun96
Copy link
Contributor

tbraun96 commented Aug 3, 2024

This commit already has this attribute for responses and requests: f6cc31b

Ignore the diff for citadel-messaging/src.

I just posted today and didn't see this PR, though, I'd just copy and paste the diff into your PR here, add some tests like usual inside the types crate we have, then call it good.

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