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

Sample production configuration for Java grpc client #111

Closed
ajaydivakaran opened this issue Sep 23, 2019 · 7 comments
Closed

Sample production configuration for Java grpc client #111

ajaydivakaran opened this issue Sep 23, 2019 · 7 comments

Comments

@ajaydivakaran
Copy link

ajaydivakaran commented Sep 23, 2019

The below link talks about a single connection.
https://github.com/dgraph-io/dgraph4j#creating-a-client

Could you please elaborate what a typical production configuration would look like?
How do I create more than 1 connection, pool configuration?

@mangalaman93
Copy link
Member

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
Copy link
Member

I also raised a PR to update README #114

@ajaydivakaran
Copy link
Author

ajaydivakaran commented Oct 1, 2019

In your example mentioned above is 3 instances of Alpha running and listening on ports (9080, 9082, 9083)?

@mangalaman93
Copy link
Member

Correct, and all of them running locally (localhost). You will have to use the correct IP for each instance.

@ajaydivakaran
Copy link
Author

How about for a single Alpha instance. Is there a way to have multiple connections to it?

@mangalaman93
Copy link
Member

For that, you can potentially pass multiple stubs to same Alpha node, though, I think that's not really very useful.

@ajaydivakaran
Copy link
Author

ok. Thanks @mangalaman93 for your suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants