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 ClientRequestContextBuilder
and ServiceRequestContextBuilder
#1548
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1548 +/- ##
============================================
- Coverage 72.62% 72.48% -0.15%
- Complexity 7249 7313 +64
============================================
Files 677 681 +4
Lines 29326 29628 +302
Branches 3579 3601 +22
============================================
+ Hits 21299 21475 +176
- Misses 6177 6276 +99
- Partials 1850 1877 +27
Continue to review full report at Codecov.
|
core/src/main/java/com/linecorp/armeria/client/ClientRequestContext.java
Show resolved
Hide resolved
/** | ||
* Returns a new {@link ClientRequestContextBuilder} created from the specified {@link RpcRequest} and URI. | ||
*/ | ||
public static ClientRequestContextBuilder of(RpcRequest request, String uri) { |
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.
Why does ClientRequestContextBuilder
accept RpcRequest
but not ServiceRequestContextBuilder
? If the use case is for a server that processes messages from Kafka, for example, it seems like a service (the client is whoever published the message).
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.
Because a ServiceRequestContext
's request has been always an HttpRequest
? For instance, ServiceRequestContext.service()
always returns Service<HttpRequest, HttpResponse>
. We may want to change this if we support more than HTTP but I guess it would be hard to occur at the moment.
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.
In that case what would it look like to model the kafka request with ServiceRequestContext
? Would it need a dummy HTTP request? I'm trying to understand how this will solve the use case, at first I expected to create a ServiceRequestContext
with RpcRequest.of(KafkaService.class
or something
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.
Yes, a dummy HTTP request will be required. A user may want to set some custom attributes as well.
core/src/main/java/com/linecorp/armeria/client/ClientRequestContext.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/AbstractRequestContextBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/AbstractRequestContextBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/util/EventLoopGroups.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/DefaultServiceRequestContext.java
Outdated
Show resolved
Hide resolved
Motivation: - It is often hard to create a mock of a `RequestContext`. - Sometimes a user want to emulate an incoming request and feed it into his or her processing pipeline. Modifications: - Added `AbstractRequestContextBuilder`. - Added `ClientRequestContextBuilder`. - Added `ServiceRequestContextBuilder`. - Added more variants of `startRequest()`, `endRequest()`, `startResponse()` and `endResponse()` to `RequestLogBuilder` so that a user can specify exact timestamps for easier matching. - Updated most test cases to use the builder instead of mocks. Result: - Closes line#1464
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/logging/RequestLogBuilder.java
Outdated
Show resolved
Hide resolved
...ure/src/test/java/com/linecorp/armeria/spring/web/reactive/ArmeriaServerHttpRequestTest.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.
Great job!
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.
Great job!
core/src/test/java/com/linecorp/armeria/internal/annotation/AnnotatedValueResolverTest.java
Outdated
Show resolved
Hide resolved
Thanks for reviewing. |
…ine#1548) Motivation: - It is often hard to create a mock of a `RequestContext`. - Sometimes a user want to emulate an incoming request and feed it into his or her processing pipeline. For example, if a user implemented complex logic which pulls some common information like socket addresses and custom attributes from `RequestContext`, the user might want to create a `ServiceRequestContext` for a request which was streamed from other source than Armeria, such as a Kafka queue. Modifications: - Added `AbstractRequestContextBuilder`. - Added `ClientRequestContextBuilder`. - Added `ServiceRequestContextBuilder`. - Added more variants of `startRequest()`, `endRequest()`, `startResponse()` and `endResponse()` to `RequestLogBuilder` so that a user can specify exact timestamps for easier matching. - Added `RequestLog.sslSession()` - Updated most test cases to use the builder instead of mocks. Result: - Closes line#1464
Motivation:
RequestContext
.his or her processing pipeline. For example, if a user implemented complex
logic which pulls some common information like socket addresses and custom
attributes from
RequestContext
, the user might want to create aServiceRequestContext
for a request which was streamed from other sourcethan Armeria, such as a Kafka queue.
Modifications:
AbstractRequestContextBuilder
.ClientRequestContextBuilder
.ServiceRequestContextBuilder
.startRequest()
,endRequest()
,startResponse()
andendResponse()
toRequestLogBuilder
so that auser can specify exact timestamps for easier matching.
RequestLog.sslSession()
Result: