what-the-bank/sources/io/grpc/Grpc.java

51 lines
1.9 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc;
import io.grpc.Attributes;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import javax.net.ssl.SSLSession;
/* loaded from: classes6.dex */
public final class Grpc {
public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_REMOTE_ADDR = Attributes.Key.create("remote-addr");
public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_LOCAL_ADDR = Attributes.Key.create("local-addr");
public static final Attributes.Key<SSLSession> TRANSPORT_ATTR_SSL_SESSION = Attributes.Key.create("ssl-session");
@Documented
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes.dex */
public @interface TransportAttr {
}
private Grpc() {
}
public static ManagedChannelBuilder<?> newChannelBuilder(String str, ChannelCredentials channelCredentials) {
return ManagedChannelRegistry.getDefaultRegistry().newChannelBuilder(str, channelCredentials);
}
public static ManagedChannelBuilder<?> newChannelBuilderForAddress(String str, int i, ChannelCredentials channelCredentials) {
return newChannelBuilder(authorityFromHostAndPort(str, i), channelCredentials);
}
private static String authorityFromHostAndPort(String str, int i) {
try {
return new URI(null, null, str, i, null, null, null).getAuthority();
} catch (URISyntaxException e) {
StringBuilder sb = new StringBuilder("Invalid host or port: ");
sb.append(str);
sb.append(" ");
sb.append(i);
throw new IllegalArgumentException(sb.toString(), e);
}
}
public static ServerBuilder<?> newServerBuilderForPort(int i, ServerCredentials serverCredentials) {
return ServerRegistry.getDefaultRegistry().newServerBuilderForPort(i, serverCredentials);
}
}