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

Add endpoint check for OpenSergoClient #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/io/opensergo/OpenSergoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class OpenSergoClient implements AutoCloseable {

public static class Builder {

private String host;
private int port;
private String host = "localhost";
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