Skip to content

Conversation

@jdcormie
Copy link
Member

@jdcormie jdcormie commented Nov 25, 2025

io.grpc.Uri is an implementation of RFC 3986 tailored for grpc-java's needs. It lifts some of the limitations of java.net.URI that currently prevent us from resolving target URIs like intent:#Intent;... See #12244 for more.

Marked @Internal for now but the plan is to eventually use this to replace java.net.URI in our public APIs such as NameResolver.Factory.

io.grpc.Uri is an implementation of RFC 3986 tailored for grpc-java's
needs. It lifts some of the limitations of java.net.URI that currently
prevent us from resolving target URIs like intent:#Intent;...
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks nice. It's slightly strange you can't create a builder directly, but that'd just have you do Uri.create("myscheme:").toBuilder(), which seems pretty clear and guarantees there is a scheme.

@jdcormie
Copy link
Member Author

jdcormie commented Dec 5, 2025

This looks nice. It's slightly strange you can't create a builder directly, but that'd just have you do Uri.create("myscheme:").toBuilder(), which seems pretty clear and guarantees there is a scheme.

Thanks! Actually the Builder() ctor is public. My intention is for users to write code like:

Uri uri =
        new Uri.Builder()
            .setScheme("http")
            .setHost("grpc.io")
            .setPath("/index.html")
            .build();

Maybe there should be a public static newBuilder() method instead to match Attributes and CreateSubchannelArgs and MethodDescriptor ... ?

For consistency with the builder pattern elsewhere in grpc-java
@ejona86
Copy link
Member

ejona86 commented Dec 5, 2025

Ah, I see. Yeah, it would match our other APIs more to have a newBuilder(). You should probably add a note to the API that creates a builder that scheme must be set before build().

@jdcormie jdcormie merged commit eb8a63c into grpc:master Dec 5, 2025
17 checks passed
@jdcormie jdcormie deleted the uri branch December 6, 2025 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants