Skip to content

Commit

Permalink
address comment by @ikhoon
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 committed Aug 9, 2024
1 parent 55e6b4a commit e190a00
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ final boolean tryInitialize() {
final CancellationScheduler scheduler = cancellationScheduler();
if (scheduler != null) {
scheduler.updateTask(newCancellationTask());
if (ctx.responseTimeoutMode() == ResponseTimeoutMode.REQUEST_WRITE) {
if (ctx.responseTimeoutMode() == ResponseTimeoutMode.CONNECTION_ACQUIRED) {
scheduler.start();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void initTimeout() {
final CancellationScheduler responseCancellationScheduler =
ctxExtension.responseCancellationScheduler();
responseCancellationScheduler.updateTask(newCancellationTask());
if (ctx.responseTimeoutMode() == ResponseTimeoutMode.RESPONSE_READ) {
if (ctx.responseTimeoutMode() == ResponseTimeoutMode.REQUEST_SENT) {
responseCancellationScheduler.start();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
* }</pre>
* <ul>
* <li>
* If {@link ResponseTimeoutMode#RESPONSE_READ} is used, the request will go through the decorators,
* acquire a connection, and write the request. Once the response header is read, the timeout task
* will trigger immediately since 5 seconds has passed which exceeds the responseTimeout of 2 seconds.
* </li>
* <li>
* If {@link ResponseTimeoutMode#REQUEST_START} is used, the timeout task will be scheduled
* immediately on request start. The timeout task will trigger while the request goes through
* the decorator, and the request will fail before acquiring a new connection.
* </li>
* <li>
* If {@link ResponseTimeoutMode#REQUEST_SENT} is used, the request will go through the decorators,
* acquire a connection, and write the request. Once the request is fully sent, the timeout task
* will trigger immediately since 5 seconds has passed which exceeds the responseTimeout of 2 seconds.
* </li>
* </ul>
*/
@UnstableApi
Expand All @@ -49,13 +49,13 @@ public enum ResponseTimeoutMode {
REQUEST_START,

/**
* The response timeout is scheduled when the request is first written on the wire.
* The response timeout is scheduled after the connection is acquired.
*/
REQUEST_WRITE,
CONNECTION_ACQUIRED,

/**
* The response timeout is scheduled either when the response bytes are first read, or when the client
* finishes writing the request.
* The response timeout is scheduled either after the client fully writes the request
* or when the response bytes are first read.
*/
RESPONSE_READ,
REQUEST_SENT,
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ final class DefaultFlagsProvider implements FlagsProvider {
static final String DNS_CACHE_SPEC = "maximumSize=4096";
static final long DEFAULT_UNLOGGED_EXCEPTIONS_REPORT_INTERVAL_MILLIS = 10000;
static final long DEFAULT_HTTP1_CONNECTION_CLOSE_DELAY_MILLIS = 3000;
static final ResponseTimeoutMode DEFAULT_RESPONSE_TIMEOUT_MODE = ResponseTimeoutMode.RESPONSE_READ;
static final ResponseTimeoutMode DEFAULT_RESPONSE_TIMEOUT_MODE = ResponseTimeoutMode.REQUEST_SENT;

private DefaultFlagsProvider() {}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/linecorp/armeria/common/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ public static long defaultHttp1ConnectionCloseDelayMillis() {
* Returns the {@link ResponseTimeoutMode} which determines when a response timeout
* will start to be scheduled.
*
* <p>The default value of this flag is RESPONSE_READ. Specify the
* <p>The default value of this flag is REQUEST_SENT. Specify the
* {@code -Dcom.linecorp.armeria.responseTimeoutMode=ResponseTimeoutMode} JVM option to
* override the default value.
* @see ResponseTimeoutMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ default Long defaultHttp1ConnectionCloseDelayMillis() {
* Returns the {@link ResponseTimeoutMode} which determines when a response timeout
* will start to be scheduled.
*
* <p>The default value of this flag is RESPONSE_READ. Specify the
* <p>The default value of this flag is REQUEST_SENT. Specify the
* {@code -Dcom.linecorp.armeria.responseTimeoutMode=ResponseTimeoutMode} JVM option to
* override the default value.
* @see ResponseTimeoutMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void timeoutMode_requestWrite() {
final HttpRequestWriter streaming = HttpRequest.streaming(HttpMethod.POST, "/");
final HttpResponse res = server
.webClient(cb -> {
cb.responseTimeoutMode(ResponseTimeoutMode.REQUEST_WRITE);
cb.responseTimeoutMode(ResponseTimeoutMode.CONNECTION_ACQUIRED);
cb.responseTimeout(Duration.ofMillis(50));
})
.execute(streaming);
Expand All @@ -82,7 +82,7 @@ void timeoutMode_requestWrite() {
void timeoutMode_responseWrite() {
final HttpResponse res = server
.webClient(cb -> {
cb.responseTimeoutMode(ResponseTimeoutMode.RESPONSE_READ);
cb.responseTimeoutMode(ResponseTimeoutMode.REQUEST_SENT);
cb.responseTimeout(Duration.ofMillis(50));
})
.get("/");
Expand Down

0 comments on commit e190a00

Please sign in to comment.