how to use grpc java load balancing library with a list of server ip address directly

22 views
Skip to first unread message

eleano...@gmail.com

unread,
Aug 20, 2018, 4:11:41 PM8/20/18
to grpc.io
Hi, 

I would like to use the grpc java load balancing library, I looked at the example code, it looks like below:

public HelloWorldClient(String zkAddr) {
this(ManagedChannelBuilder.forTarget(zkAddr)
.loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
.nameResolverFactory(new ZkNameResolverProvider())
.usePlaintext(true));
}

I would like to pass ManagedChannelBuilder a list of service ip addresses directly, rather than let a NameResolver to resolve for me. Then I still
want to use .loadBalancerFactory(roundRobinLoadBalancerFactory.getInstance()),

if there a way to do it ?

Thanks a lot!

Carl Mastrangelo

unread,
Aug 20, 2018, 9:56:42 PM8/20/18
to grpc.io
Look in the gRPC source code for DirectAddressNameResolverFactory, which you can copy into your project.  This does what you want.
Reply all
Reply to author
Forward
0 new messages