Page MenuHomePhabricator

[tunnelbroker-client] Adding `publish_message` client function
ClosedPublic

Authored by max on Jan 17 2023, 6:58 AM.
Tags
None
Referenced Files
F3247387: D6284.diff
Fri, Nov 15, 5:01 AM
F3245142: D6284.id22625.diff
Thu, Nov 14, 4:43 PM
Unknown Object (File)
Fri, Nov 8, 10:44 PM
Unknown Object (File)
Fri, Nov 8, 10:09 AM
Unknown Object (File)
Fri, Nov 8, 10:09 AM
Unknown Object (File)
Fri, Nov 8, 10:09 AM
Unknown Object (File)
Fri, Nov 8, 10:09 AM
Unknown Object (File)
Fri, Nov 8, 10:09 AM
Subscribers

Details

Summary

This diff introduces a publish_message client function for the shared Tunnelbroker client library.
The function handles publishing message payload to the gRPC stream which is bind to the mpsc tx argument.

Linear task: ENG-2728

Test Plan
  1. Keyserver service is successfully built.
  2. The function is used in the following D6460 in a NAPI-RS bridge function

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max held this revision as a draft.

Updating to use tx mspc to publish.

Updating on the parent changes.

max published this revision for review.Jan 30 2023, 2:48 AM
max edited the summary of this revision. (Show Details)
shared/tunnelbroker-client/src/lib.rs
32–49 ↗(On Diff #21553)

Since we await, do we really need to decorate the function with async?

Also, I think we can just return the result of await (not sure if this will cause type issues).

varun requested changes to this revision.Jan 31 2023, 9:13 PM

just one question inline

shared/tunnelbroker-client/src/lib.rs
8 ↗(On Diff #21553)

it's kind of weird that we are calling this module protobuff, i think protobuf is the standard nomenclature

32–49 ↗(On Diff #21553)

any function where you await requires the async keyword

40–44 ↗(On Diff #21553)

why are we using a vector if there's only one message?

This revision now requires changes to proceed.Jan 31 2023, 9:13 PM
max added inline comments.
shared/tunnelbroker-client/src/lib.rs
8 ↗(On Diff #21553)

it's kind of weird that we are calling this module protobuff, i think protobuf is the standard nomenclature

Makes sense to change it to a more specific name. That name came from the parent D6281, I've changed it to the tunnelbroker_pb.

32–49 ↗(On Diff #21553)

Since we await, do we really need to decorate the function with async?

Yes, we should decorate it with async because we are calling await inside.

Also, I think we can just return the result of await (not sure if this will cause type issues).

Unfortunately, this causes a type issue, that's why such construction is used here.

40–44 ↗(On Diff #21553)

why are we using a vector if there's only one message?

Makes sense to pass a vector to this function as it's a shared client library, despite that in our current scenario we will publish one message in a napi-rs bridge.
I've changed it. Thanks @varun !

This revision is now accepted and ready to land.Feb 2 2023, 11:32 AM
shared/tunnelbroker-client/src/lib.rs
30 ↗(On Diff #21839)

this should probably be called publish_messages, right?

max marked 2 inline comments as done.

Fix function name to plural.

max added inline comments.
shared/tunnelbroker-client/src/lib.rs
30 ↗(On Diff #21839)

this should probably be called publish_messages, right?

Absolutely! Thanks for catching it. Fixed.

max marked an inline comment as done.

Rebasing on master changes.