Skip to content

Commit

Permalink
check endpoint of OpenSergoClient
Browse files Browse the repository at this point in the history
Signed-off-by: Jiangnan Jia <jnan0806@gmail.com>
  • Loading branch information
jnan806 committed Feb 15, 2023
1 parent bd5f15f commit 3a5bd92
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/io/opensergo/OpenSergoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class OpenSergoClient implements AutoCloseable {
public static class Builder {

private String host;
private int port;
private int port = 10246;
private OpenSergoClientConfig openSergoConfig;

public OpenSergoClient.Builder endpoint(String host, int port) {
Expand Down Expand Up @@ -83,6 +83,7 @@ public OpenSergoClient(String host, int port) {
}

public OpenSergoClient(String host, int port, OpenSergoClientConfig clientConfig) {
checkEndpoint(host, port);
checkClientConfig(clientConfig);
// TODO: support TLS
this.clientConfig = clientConfig;
Expand All @@ -95,6 +96,11 @@ public OpenSergoClient(String host, int port, OpenSergoClientConfig clientConfig
this.reqId = new AtomicInteger(0);
}

private void checkEndpoint(String host, int port) {
AssertUtils.notEmpty(host, "host cannot be empty, need to give a valid host");
AssertUtils.isTrue(port > 0, "port < 1 is invalid, need to give a valid port");
}

private void checkClientConfig(OpenSergoClientConfig clientConfig) {
AssertUtils.assertNotNull(clientConfig, "clientConfig cannot be null");
}
Expand Down

0 comments on commit 3a5bd92

Please sign in to comment.