-
Notifications
You must be signed in to change notification settings - Fork 921
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() #5761
Conversation
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
Some of the descriptions in the Modifications field contain Korean.
p.s. It's an interesting feature, so I'm watching with interest |
Thank you for your interest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Please make the build pass as well.
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
Last but not least, please sign the ICLA. |
I checked, thank you for your review. |
7c52cef
to
d1ea297
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly done 👍 Left a couple of comments regarding edge cases
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Show resolved
Hide resolved
Unsubscribing due to a timeout does not guarantee synchronization with upstream. Therefore, we implemented an attempt attemptTerminate() method.
Lint error correction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Left a few suggestions. 👍
core/src/main/java/com/linecorp/armeria/common/stream/StreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/StreamMessage.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/StreamMessage.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still Looks good. 👍 Left a few more suggestions.
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few more suggestions. 😉
core/src/main/java/com/linecorp/armeria/common/stream/StreamTimeoutMode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/stream/TimeoutStreamMessageTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutSubscriber.java
Outdated
Show resolved
Hide resolved
2. add docs to StreamTimeoutMode parameter 3. use test code executor.get()
…and set the timeout schedule 2. change TimeoutSubscriber class to TimeoutStreamMessage's inner class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks a lot, @sjy982! 😆
core/src/main/java/com/linecorp/armeria/common/stream/StreamTimeoutMode.java
Outdated
Show resolved
Hide resolved
251daf7
to
73adfff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some nit comments, basically looks good 👍 👍 👍
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
…meoutMode` 2. Added leak prevention code when completed in onNext() - PooledObjects.close(t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to revise and proofread Javadoc but the implementation looks look.
core/src/main/java/com/linecorp/armeria/common/stream/StreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/StreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/stream/TimeoutStreamMessage.java
Outdated
Show resolved
Hide resolved
2. Add a StreamTimeoutException 3. Overriding WebSocket's timeout method 4. Remove cancelSchedule() from abort() 5. Set timeoutFuture to null to avoid calling .isCancelled() which may access a volatile field. 6. Modify boolean cancels to volatile boolean cancels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @sjy982! 💯🚀
Motivation:
Currently, the
aggregate()
andsubscribe()
methods ofStreamMessage
do not have the ability to set a timeout. This provides the ability to detect when a client or server has not responded for a period of time and handle it appropriately. Additionally, the timeout API can be used to detect idle streams by setting a timeout until the next message.Modifications:
TimeoutStreamMessage
classStreamMessage
to provide timeout functionalitytimeout()
method to theStreamMessage
interface.TimeoutSubscriber
classStreamTimeoutMode
allows you to set different timeout modes.StreamTimeoutMode
enumerationUNTIL_FIRST
,UNTIL_NEXT
, andUNTIL_EOS
modes.timeout
method to theStreamMessage
,HttpResponse
, andHttpRequest
interfaces to provide the ability to set a timeout.Result:
StreamMessage.timeout()
#5744aggregate()
andsubscribe()
methods ofStreamMessage
and HTTP requests/responses.StreamTimeoutMode
to set the timeout between the arrival of the first message, the arrival of the next message, or the end of the stream.