forked from TrueCloudLab/frostfs-sdk-java
[#1] code cleanup
update README.md Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
parent
b0db7df192
commit
a7fab6f314
28 changed files with 177 additions and 203 deletions
|
@ -1,26 +0,0 @@
|
|||
package info.FrostFS.sdk;
|
||||
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.ChannelCredentials;
|
||||
import io.grpc.netty.NettyChannelBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class GrpcClient {
|
||||
|
||||
public static Channel initGrpcChannel(String host, ChannelCredentials creds) {
|
||||
try {
|
||||
URI uri = new URI(host);
|
||||
var channelBuilder = isNull(creds) ? NettyChannelBuilder.forAddress(uri.getHost(), uri.getPort())
|
||||
: NettyChannelBuilder.forAddress(uri.getHost(), uri.getPort(), creds);
|
||||
|
||||
return channelBuilder.usePlaintext().build();
|
||||
} catch (URISyntaxException exp) {
|
||||
var message = String.format("Host %s has invalid format. Error: %s", host, exp.getMessage());
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue