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

Avoid deprecated nameResolverFactory #296

Open
laglangyue opened this issue Apr 14, 2024 · 1 comment
Open

Avoid deprecated nameResolverFactory #296

laglangyue opened this issue Apr 14, 2024 · 1 comment

Comments

@laglangyue
Copy link
Contributor

laglangyue commented Apr 14, 2024

I was reading the code for name solver and found a todo item, hoping to resolve it.

motivation

same issue in akka-grpc akka/akka-grpc#1092

code in pekko org.apache.pekko.grpc.internal.NettyClientUtils

@nowarn("cat=deprecation")
var builder =
NettyChannelBuilder
// Not sure why netty wants to be able to shoe-horn the target into a URI... but ok,
// we follow their lead and encode the service name as the 'authority' of the URI.
.forTarget("//" + settings.serviceName)
.flowControlWindow(NettyChannelBuilder.DEFAULT_FLOW_CONTROL_WINDOW)
// TODO avoid nameResolverFactory #1092, then 'nowarn' can be removed above
.nameResolverFactory(
new PekkoDiscoveryNameResolverProvider(
settings.serviceDiscovery,
settings.defaultPort,
settings.serviceName,
settings.servicePortName,
settings.serviceProtocol,
settings.resolveTimeout))

changes

according to grpc-java

https://github.com/grpc/grpc-java/blob/497e1552172632107574d67d7c092a3f5a39a980/examples/src/main/java/io/grpc/examples/nameresolve/NameResolveClient.java#L39

we just need

NameResolverRegistry.getDefaultRegistry.register(
      new PekkoDiscoveryNameResolverProvider(
        settings.serviceDiscovery,
        settings.defaultPort,
        settings.serviceName,
        settings.servicePortName,
        settings.serviceProtocol,
        settings.resolveTimeout))
@laglangyue
Copy link
Contributor Author

@raboof
Akka's issue was created by you. Do you have any ideas?
Should we add a PekkoNameResolverRegister to wrapper the NameResolverRegistry in grpc-java?

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

No branches or pull requests

1 participant