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 custom NameResolver.Args #11669

Merged
merged 28 commits into from
Dec 20, 2024
Merged

Conversation

jdcormie
Copy link
Member

@jdcormie jdcormie commented Nov 6, 2024

grpc-binder's upcoming IntentNameResolver needs to know the target Android user so it can resolve target URIs in the correct place. Unfortunately, Android's built in intent:// URI scheme has no way to specify a user and in fact the android.os.UserHandle object can't reasonably be encoded as a String at all.

We solve this problem by extending NameResolver.Args to permit externally defined arguments using the same type-safe and domain-specific Key<T> pattern used by CallOptions, Context and CreateSubchannelArgs. New "custom" arguments could apply to all NameResolvers of a certain URI scheme, to all NameResolvers producing a particular type of java.net.SocketAddress, or even to a specific NameResolver subclass.

@jdcormie jdcormie requested a review from ejona86 November 6, 2024 04:52
@jdcormie jdcormie added the kokoro:force-run Add this label to a PR to tell Kokoro to re-run all tests. Not generally necessary label Nov 8, 2024
@grpc-kokoro grpc-kokoro removed the kokoro:force-run Add this label to a PR to tell Kokoro to re-run all tests. Not generally necessary label Nov 8, 2024
@jdcormie
Copy link
Member Author

Friendly 1 week ping. This is the domain-specific Key<>-based approach you requested in our last meeting.

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.

I like how Extensions was implemented to avoid copying the map on build().

api/src/main/java/io/grpc/NameResolver.java Outdated Show resolved Hide resolved
api/src/main/java/io/grpc/NameResolver.java Outdated Show resolved Hide resolved
api/src/main/java/io/grpc/NameResolver.java Outdated Show resolved Hide resolved
api/src/main/java/io/grpc/NameResolver.java Outdated Show resolved Hide resolved
api/src/main/java/io/grpc/NameResolver.java Outdated Show resolved Hide resolved
api/src/main/java/io/grpc/NameResolver.java Show resolved Hide resolved
Fully remove Args.Extensions from the public API (@internal)
Make TODO non-javadoc
google-java-format
unused imports
@jdcormie
Copy link
Member Author

I like how Extensions was implemented to avoid copying the map on build().

👍 I can't take credit though, just copy pasted from Attributes. LMK if you think one of the other special-purpose containers would be a better fit.

@jdcormie jdcormie closed this Nov 20, 2024
@jdcormie jdcormie reopened this Nov 20, 2024
@jdcormie
Copy link
Member Author

Friendly ping :)

@jdcormie
Copy link
Member Author

jdcormie commented Dec 9, 2024

Friendly 2 week ping 🙂

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.

Sending what I have. It is proof at least I looked at this today.

api/src/main/java/io/grpc/NameResolver.java Outdated Show resolved Hide resolved
@jdcormie
Copy link
Member Author

Gentle weekly ping

Call these "custom" args rather than extensions for consistency with
CallOptions.
@jdcormie jdcormie changed the title Introduce NameResolver.Args.Extensions Introduce custom NameResolver.Args Dec 17, 2024
@jdcormie
Copy link
Member Author

jdcormie commented Dec 18, 2024

NameResolver.Args.Extensions no longer exists.

Call these "custom" args to match CallOptions terminology.

PTAL

@jdcormie jdcormie requested a review from ejona86 December 19, 2024 19:11
@jdcormie jdcormie merged commit 0b2d440 into grpc:master Dec 20, 2024
16 checks passed
@ejona86
Copy link
Member

ejona86 commented Dec 20, 2024

FYI, @anicr7 @AshZhang, this might be helpful in XdsNameResolver to communicate between nested NameResolvers.

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.

3 participants