diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-09-02 16:42:10 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-09-02 16:42:10 +0200 |
commit | 3c9de78274d5f7e5d7c7c19105e4925a91103e9e (patch) | |
tree | 1e0027dc08663b890ecdc9b68b6543fadb394691 /jdisc_core | |
parent | 5a10a3cc2bbad52d783e75a92c1527e33e976fe9 (diff) |
Allow setting a request type explicitly
This lets handler authors control the requestType explicitly
by setting it on the HttpResponse, which is useful to avoid
misclassification of POST requests to reading handlers as writes.
Diffstat (limited to 'jdisc_core')
-rw-r--r-- | jdisc_core/src/main/java/com/yahoo/jdisc/Request.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java index e0292bbe026..bce6f72c1fc 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java @@ -48,6 +48,11 @@ public class Request extends AbstractResource { private boolean serverRequest; private Long timeout; private URI uri; + private RequestType requestType; + + public enum RequestType { + READ, WRITE, MONITORING + } /** * <p>Creates a new instance of this class. As a {@link ServerProvider} you need to inject a {@link @@ -326,6 +331,12 @@ public class Request extends AbstractResource { return unit.convert(creationTime, TimeUnit.MILLISECONDS); } + /** Sets the type classification of this request for metric collection purposes */ + public void setRequestType(RequestType requestType) { this.requestType = requestType; } + + /** Returns the type classification of this request for metric collection purposes, or null if not set */ + public RequestType getRequestType() { return requestType; } + /** * <p>Returns whether or not this Request has been cancelled. This can be thought of as the {@link * Thread#isInterrupted()} of Requests - it does not enforce anything in ways of blocking the Request, it is simply |