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

Add DataStreamBidirectional API #202

Merged
merged 11 commits into from
Mar 2, 2024

Conversation

corbin-phipps
Copy link
Contributor

Type

  • Bug fix
  • Feature addition
  • Feature update
  • Documentation
  • Build Infrastructure

Side Effects

  • Breaking change
  • Non-functional change

Goals

This PR adds the DataStreamBidirectional API along with a unit test.

Technical Details

  • Added DataStreamBidirectional API to NetRemoteDataStreamingService.proto.
  • Added DataStreamReaderWriter implementation of the gRPC ServerBidiReactor to NetRemoteDataStreamingReactors.
  • Added DataStreamReaderWriter implementation of the gRPC ClientBidiReactor to TestNetRemoteDataStreamingReactors.
  • Added unit test to TestNetRemoteDataStreamingServiceClient.

Test Results

All tests pass.

Reviewer Focus

None.

Future Work

Checklist

  • Build target all compiles cleanly.
  • clang-format and clang-tidy deltas produced no new output.
  • Newly added functions include doxygen-style comment block.

@corbin-phipps corbin-phipps requested a review from a team as a code owner March 2, 2024 02:39
}

// Create data to write to the client.
const auto data = m_dataGenerator.GenerateRandomData();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there plans to allow configuration of the block size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not currently. Because this API doesn't have a "request"/"response" like regular RPCs and instead has a "stream" for both directions, there is no intuitive way to allow the client to specify a block size that it wants the server to use. I think that if there was a scenario that required that, then the DataStreamDownload API should be used instead

Copy link
Contributor

@abeltrano abeltrano Mar 2, 2024

Choose a reason for hiding this comment

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

If this is a requirement (I think it is), there are a few ways we could consider achieving this:

  1. Since all fields are optional in proto3 format, the first input message from the client could populate a field that specifies properties about the requested stream from the server. This field is only inspected on the first message received and otherwise not even checked for.
  2. Streaming could be stateful, where a request is first made to create a stream, and then that stream has to be explicitly started with the usual API. This way, both the client and server can negotiate stream properties. It could look something like this:
enum DataStreamDirection
{
    Upload,
    Download,
    Both,
};
enum DataStreamCreateStatusCode 
{
    Unknown = 0,
    Succeeded = 1,
    Failed = 2,
    // Others as needed
};
message DataStreamCreateRequest
{
    DataStreamDirection Direction = 1;
    DataStreamProperties PropertiesUpload = 2; // present when Direction == Upload and Both
    DataStreamProperties PropertiesDownload = 2; // present when Direction == Download and Both
};
message DataStreamCreateResult
{
    DataStreamCreateStatusCode Status = 0;
    string StreamId = 1; // Valid/present only when  Status == Succeeded
};
message DataStreamDownloadRequest
{
    string StreamId = 0;
};
rpc DataStreamCreate (DataStreamCreateRequest request, DataStreamCreateResult result);

The server doesn't strictly need upload stream properties since it's just a sink and will just drop everything it receives, however, that information would also enable the server to do accounting on the streaming operation. This could be useful in triaging failures in case the problem on the client side somehow precludes correct accounting, and, it would also be useful to be able to compare accounting on each side to make sure it matched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracking this in #206 and will look into it later. Your first suggestion is definitely simpler and stays closer to the original design, but your second suggestion is cleaner and simple to understand, although requires a bit more work and changes the design a bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Both require logic on the server side to check for the presence of a field, and while intuitive for the client, having conditional logic like that feels wrong. Anyway, we can drill into this as part of #206 after we determine if this is really a requirement of not.

tests/unit/TestNetRemoteDataStreamingReactors.hxx Outdated Show resolved Hide resolved
tests/unit/TestNetRemoteDataStreamingServiceClient.cxx Outdated Show resolved Hide resolved
@corbin-phipps corbin-phipps merged commit ba994ad into feature/dataStreaming Mar 2, 2024
1 check passed
@corbin-phipps corbin-phipps deleted the user/corbinphipps/add-bidi-api branch March 2, 2024 03:45
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.

2 participants