-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+htc akka#16819 implement server-side request timeouts
- Loading branch information
Showing
12 changed files
with
360 additions
and
27 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
akka-http-core/src/main/java/akka/http/javadsl/TimeoutAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
|
||
package akka.http.javadsl; | ||
|
||
import akka.http.javadsl.model.HttpRequest; | ||
import akka.http.javadsl.model.HttpResponse; | ||
import akka.japi.Function; | ||
import scala.concurrent.duration.Duration; | ||
|
||
/** | ||
* Enables programmatic access to the server-side request timeout logic. | ||
*/ | ||
public interface TimeoutAccess { | ||
|
||
/** | ||
* Tries to set a new timeout. | ||
* The timeout period is measured as of the point in time that the end of the request has been received, | ||
* which may be in the past or in the future! | ||
* Use `Duration.Inf` to completely disable request timeout checking for this request. | ||
* | ||
* Due to the inherent raciness it is not guaranteed that the update will be applied before | ||
* the previously set timeout has expired! | ||
*/ | ||
void updateTimeout(Duration timeout); | ||
|
||
/** | ||
* Tries to set a new timeout handler, which produces the timeout response for a | ||
* given request. Note that the handler must produce the response synchronously and shouldn't block! | ||
* | ||
* Due to the inherent raciness it is not guaranteed that the update will be applied before | ||
* the previously set timeout has expired! | ||
*/ | ||
void updateHandler(Function<HttpRequest, HttpResponse> handler); | ||
|
||
/** | ||
* Tries to set a new timeout and handler at the same time. | ||
* | ||
* Due to the inherent raciness it is not guaranteed that the update will be applied before | ||
* the previously set timeout has expired! | ||
*/ | ||
void update(Duration timeout, Function<HttpRequest, HttpResponse> handler); | ||
} |
16 changes: 16 additions & 0 deletions
16
akka-http-core/src/main/java/akka/http/javadsl/model/headers/TimeoutAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
|
||
package akka.http.javadsl.model.headers; | ||
|
||
/** | ||
* Model for the synthetic `Timeout-Access` header. | ||
*/ | ||
public abstract class TimeoutAccess extends akka.http.scaladsl.model.HttpHeader { | ||
public abstract akka.http.javadsl.TimeoutAccess timeoutAccess(); | ||
|
||
public static TimeoutAccess create(akka.http.javadsl.TimeoutAccess timeoutAccess) { | ||
return new akka.http.scaladsl.model.headers.Timeout$minusAccess((akka.http.scaladsl.TimeoutAccess) timeoutAccess); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
akka-http-core/src/main/scala/akka/http/scaladsl/TimeoutAccess.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
|
||
package akka.http.scaladsl | ||
|
||
import scala.concurrent.duration.Duration | ||
import akka.http.scaladsl.model.{ HttpResponse, HttpRequest } | ||
|
||
/** | ||
* Enables programmatic access to the server-side request timeout logic. | ||
*/ | ||
trait TimeoutAccess extends akka.http.javadsl.TimeoutAccess { | ||
|
||
/** | ||
* Tries to set a new timeout. | ||
* The timeout period is measured as of the point in time that the end of the request has been received, | ||
* which may be in the past or in the future! | ||
* Use `Duration.Inf` to completely disable request timeout checking for this request. | ||
* | ||
* Due to the inherent raciness it is not guaranteed that the update will be applied before | ||
* the previously set timeout has expired! | ||
*/ | ||
def updateTimeout(timeout: Duration): Unit | ||
|
||
/** | ||
* Tries to set a new timeout handler, which produces the timeout response for a | ||
* given request. Note that the handler must produce the response synchronously and shouldn't block! | ||
* | ||
* Due to the inherent raciness it is not guaranteed that the update will be applied before | ||
* the previously set timeout has expired! | ||
*/ | ||
def updateHandler(handler: HttpRequest ⇒ HttpResponse): Unit | ||
|
||
/** | ||
* Tries to set a new timeout and handler at the same time. | ||
* | ||
* Due to the inherent raciness it is not guaranteed that the update will be applied before | ||
* the previously set timeout has expired! | ||
*/ | ||
def update(timeout: Duration, handler: HttpRequest ⇒ HttpResponse): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.