Skip to content
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

Introduce the notion of a default SessionProtocol #6128

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jrhee17
Copy link
Contributor

@jrhee17 jrhee17 commented Feb 26, 2025

Motivation:

It has been suggested that SessionProtocol.UNDEFINED be avoided at #6060 (comment), and a default SessionProtocol for clients is introduced.

A client can now be created without the user explicitly providing a SessionProtocol. By default SessionProtocol.HTTP will be used. For clients that are created with a String, users will be able to use the default SessionProtocol via scheme relative URIs as defined in the following rfc.

WebClient.builder("//armeria.dev").build()
WebClient.builder(new URI(null, "armeria.dev", null, null)).build()
WebClient.builder(Endpoint.of("armeria.dev")
WebClient.builder(Endpoint.of("armeria.dev"), "/").build()
WebClient.of().blocking().get("//armeria.dev/hello")

One point to note is that RequestTarget may be parsed different depending on whether the input is a path, or a uri.
In the context of a path, //my-path is a completely valid path whereas in the context of a URI, //my-path will be a uri with authority my-path.
In order to address this, DefaultRequestTarget#forClientPath has been introduced.

Possibly breaking behavior is that requests cannot be made using a path starting with //.

Modifications:

  • Added factory methods to use the default SessionProtocol as defined by SessionProtocolUtil#defaultSessionProtocol.
  • Added scheme-relative URI handling logic when parsing the authority in RequestTarget#forClient
  • Added RequestTarget#forClientPath and modified existing callers to use the new API when applicable

Result:

  • Users may create a client without explicitly specifying the SessionProtocol

@jrhee17 jrhee17 added this to the 1.33.0 milestone Feb 26, 2025
@jrhee17 jrhee17 marked this pull request as ready for review February 26, 2025 10:11
@jrhee17 jrhee17 marked this pull request as draft February 27, 2025 02:19
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 84.09091% with 14 lines in your changes missing coverage. Please review.

Project coverage is 74.40%. Comparing base (3b27340) to head (f9cb6bd).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...rp/armeria/internal/common/RequestTargetCache.java 66.66% 0 Missing and 3 partials ⚠️
.../linecorp/armeria/client/thrift/ThriftClients.java 57.14% 3 Missing ⚠️
...p/armeria/internal/client/SessionProtocolUtil.java 71.42% 2 Missing ⚠️
...orp/armeria/client/eureka/EurekaEndpointGroup.java 0.00% 2 Missing ⚠️
.../armeria/server/eureka/EurekaUpdatingListener.java 0.00% 2 Missing ⚠️
.../com/linecorp/armeria/client/grpc/GrpcClients.java 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6128      +/-   ##
============================================
- Coverage     74.44%   74.40%   -0.04%     
- Complexity    22059    22219     +160     
============================================
  Files          1942     1960      +18     
  Lines         82033    82333     +300     
  Branches      10736    10740       +4     
============================================
+ Hits          61070    61262     +192     
- Misses        15854    15948      +94     
- Partials       5109     5123      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jrhee17 jrhee17 marked this pull request as ready for review February 27, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant