Skip to content

Commit

Permalink
Add method to send stream payload
Browse files Browse the repository at this point in the history
Summary:
Implement the streaming flow control. These diffs are equivalent to `ServerGeneratorStream::fromAsyncGeneratorImpl`

https://www.internalfb.com/code/fbsource/fbcode/thrift/lib/cpp2/async/ServerGeneratorStream-inl.h?lines=22-100

Add a method to send Payload

1. Payload is only sent if previous call to `genIsStreamReady` or `genSendPayload` returns true.
2. `genSendPaylaod` published the payload and then checks if server still has credits and stream is not paused.
 i) If there are no credits and stream is not paused, then wait for more credits before returning.
 ii) Process client messages and return `?bool` as per the state of the stream
3. send stream complete if no more payloads left.

------------------------------
Flow diagram

 {F1698728124}

Reviewed By: AkramaMirza

Differential Revision: D55172705

fbshipit-source-id: 1ad157cdba45c11d1ba291b94e220d283852c506
  • Loading branch information
Rashmi Makheja authored and facebook-github-bot committed Jun 25, 2024
1 parent 3b6460f commit f3401c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions thrift/lib/cpp2/async/ServerGeneratorStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ class ServerGeneratorStream : public TwoWayBridge<

bool wait(ServerStreamConsumer* consumer);

void publish(folly::Try<StreamPayload>&& payload);

private:
ServerGeneratorStream(
StreamClientCallback* clientCallback, folly::EventBase* clientEb);

void publish(folly::Try<StreamPayload>&& payload);

bool onStreamRequestN(uint64_t credits) override;

void onStreamCancel() override;
Expand Down

0 comments on commit f3401c4

Please sign in to comment.