Posted by ajaydivakaran:
The below link talks about a single connection.
Could you please elaborate what a typical production configuration would look like?
How do I create more than 1 connection, pool configuration?
Posted by ajaydivakaran:
The below link talks about a single connection.
Could you please elaborate what a typical production configuration would look like?
How do I create more than 1 connection, pool configuration?
mangalaman93 commented :
You can create as many stubs as there are Alpha nodes running -
ManagedChannel channel1 = ManagedChannelBuilder
.forAddress("localhost", 9080)
.usePlaintext().build();
DgraphStub stub1 = DgraphGrpc.newStub(channel1);
ManagedChannel channel2 = ManagedChannelBuilder
.forAddress("localhost", 9082)
.usePlaintext().build();
DgraphStub stub2 = DgraphGrpc.newStub(channel2);
ManagedChannel channel3 = ManagedChannelBuilder
.forAddress("localhost", 9083)
.usePlaintext().build();
DgraphStub stub3 = DgraphGrpc.newStub(channel3);
DgraphClient dgraphClient = new DgraphClient(stub1, stub2, stub3);
mangalaman93 commented :
I also raised a PR to update README Fix Creating a Client section in README by mangalaman93 · Pull Request #114 · dgraph-io/dgraph4j · GitHub
ajaydivakaran commented :
In your example mentioned above is 3 instances of Alpha running and listening on ports (9080, 9082, 9083)?
mangalaman93 commented :
Correct, and all of them running locally (localhost). You will have to use the correct IP for each instance.
ajaydivakaran commented :
How about for a single Alpha instance. Is there a way to have multiple connections to it?
mangalaman93 commented :
For that, you can potentially pass multiple stubs to same Alpha node, though, I think that’s not really very useful.
ajaydivakaran commented :
ok. Thanks @mangalaman93 for your suggestions.