Skip to content

Commit

Permalink
add parameter for MaxInBoundMessageSize
Browse files Browse the repository at this point in the history
  • Loading branch information
gumreal authored and gumreal committed Mar 12, 2022
1 parent cb10e9b commit 54d16a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ apply plugin: 'signing'

group = 'io.dgraph'
archivesBaseName = 'dgraph4j'
version = '21.03.2.p15.20220310b'
version = '21.03.2.p16.20220312a'
sourceCompatibility = 1.8
targetCompatibility = 1.8

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/io/dgraph/wrapper/ClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ClientBuilder {
private Logger logger = LoggerFactory.getLogger(ClientBuilder.class.getName());
private Set<String> uriSet = new HashSet<>();
private List<AlphaUri> alphaList = new ArrayList<>();
private int maxInBoundBytes = 4 * 1024 * 1024;

private ClientBuilder() {}

Expand All @@ -30,6 +31,10 @@ public static ClientBuilder newInstance() {
* @throws WrapperException
*/
public ClientBuilder withAlpha(String host, int port) throws WrapperException {
return withAlpha(host, port, 0);
}

public ClientBuilder withAlpha(String host, int port, int maxInBytes) throws WrapperException {
if (GeneralHelper.isEmpty(host) || port <= 0) {
throw new WrapperException("invalid alpha uri");
}
Expand All @@ -41,6 +46,10 @@ public ClientBuilder withAlpha(String host, int port) throws WrapperException {
alphaList.add(new AlphaUri(host, port));
}

if (maxInBytes > this.maxInBoundBytes) {
this.maxInBoundBytes = maxInBytes;
}

return this;
}

Expand All @@ -67,7 +76,11 @@ public DgraphClient build() throws WrapperException {
* @return
*/
private DgraphGrpc.DgraphStub makeStub(String addr, int port) {
ManagedChannel channel = ManagedChannelBuilder.forAddress(addr, port).usePlaintext().build();
ManagedChannel channel =
ManagedChannelBuilder.forAddress(addr, port)
.usePlaintext()
.maxInboundMessageSize(maxInBoundBytes)
.build();
return DgraphGrpc.newStub(channel);
}

Expand Down

0 comments on commit 54d16a2

Please sign in to comment.