what-the-bank/sources/io/grpc/internal/DnsNameResolverProvider.java

39 lines
1.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc.internal;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import io.grpc.InternalServiceProviders;
import io.grpc.NameResolver;
import io.grpc.NameResolverProvider;
import java.net.URI;
/* loaded from: classes6.dex */
public final class DnsNameResolverProvider extends NameResolverProvider {
private static final String SCHEME = "dns";
@Override // io.grpc.NameResolverProvider
public final boolean isAvailable() {
return true;
}
@Override // io.grpc.NameResolverProvider
public final int priority() {
return 5;
}
@Override // io.grpc.NameResolver.Factory
public final DnsNameResolver newNameResolver(URI uri, NameResolver.Args args) {
if (!SCHEME.equals(uri.getScheme())) {
return null;
}
String str = (String) Preconditions.checkNotNull(uri.getPath(), "targetPath");
Preconditions.checkArgument(str.startsWith("/"), "the path component (%s) of the target (%s) must start with '/'", str, uri);
return new DnsNameResolver(uri.getAuthority(), str.substring(1), args, GrpcUtil.SHARED_CHANNEL_EXECUTOR, Stopwatch.createUnstarted(), InternalServiceProviders.isAndroid(getClass().getClassLoader()));
}
@Override // io.grpc.NameResolver.Factory
public final String getDefaultScheme() {
return SCHEME;
}
}