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 StreamMessage.timeout() #5744

Open
ikhoon opened this issue Jun 10, 2024 · 2 comments · May be fixed by #5761
Open

Add StreamMessage.timeout() #5744

ikhoon opened this issue Jun 10, 2024 · 2 comments · May be fixed by #5761

Comments

@ikhoon
Copy link
Contributor

ikhoon commented Jun 10, 2024

Currently, there is no timeout for StreamMessage's aggregate() or subscribe(). If we want to give a timeout for HttpRequest.aggregate(), a separate scheduler needs to be run to abort the request if it is not completed within the given time.

The timeout API can also be used to detect an idle stream by setting a timeout until the next message. #5713 (comment)

enum StreamTimeoutMode {
    UNTIL_FIRST,
    // Maybe the default one
    UNTIL_NEXT,
    UNTIL_EOS // or UNTIL_LAST
}

StreamMessage<Object> stream = ...;
// Sets a timeout for each message to 5 seconds.
stream.timeout(5_seconds).subscribe(....);

// UNTIL_EOS will be useful for unary requests.
HttpRequest req = ...;
req.timeout(StreamTimeoutMode.UNTIL_EOS, 10_seconds).aggregate();
req.aggregate(10_seconds); // Shortcut

// UNTIL_NEXT will be useful for stream requests such as gRPC streams or WebSocket.
WebSocket input = ...;
input.timeout(UNTIL_NEXT, 3_seconds).subscribe(...);
@sjy982
Copy link
Contributor

sjy982 commented Jun 10, 2024

I'm in charge of this issue.

@ikhoon
Copy link
Contributor Author

ikhoon commented Jun 10, 2024

Yes, please. 🙇

@sjy982 sjy982 linked a pull request Jun 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants