本文整理汇总了Java中io.grpc.MethodDescriptor.extractFullServiceName方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDescriptor.extractFullServiceName方法的具体用法?Java MethodDescriptor.extractFullServiceName怎么用?Java MethodDescriptor.extractFullServiceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.MethodDescriptor
的用法示例。
在下文中一共展示了MethodDescriptor.extractFullServiceName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serviceUri
import io.grpc.MethodDescriptor; //导入方法依赖的package包/类
/**
* Generate a JWT-specific service URI. The URI is simply an identifier with enough information
* for a service to know that the JWT was intended for it. The URI will commonly be verified with
* a simple string equality check.
*/
private URI serviceUri(Channel channel, MethodDescriptor<?, ?> method) throws StatusException {
String authority = channel.authority();
if (authority == null) {
throw Status.UNAUTHENTICATED.withDescription("Channel has no authority").asException();
}
// Always use HTTPS, by definition.
final String scheme = "https";
final int defaultPort = 443;
String path = "/" + MethodDescriptor.extractFullServiceName(method.getFullMethodName());
URI uri;
try {
uri = new URI(scheme, authority, path, null, null);
} catch (URISyntaxException e) {
throw Status.UNAUTHENTICATED.withDescription("Unable to construct service URI for auth")
.withCause(e).asException();
}
// The default port must not be present. Alternative ports should be present.
if (uri.getPort() == defaultPort) {
uri = removePort(uri);
}
return uri;
}
示例2: serviceUri
import io.grpc.MethodDescriptor; //导入方法依赖的package包/类
/**
* Generate a JWT-specific service URI. The URI is simply an identifier with enough information
* for a service to know that the JWT was intended for it. The URI will commonly be verified with
* a simple string equality check.
*/
private static URI serviceUri(String authority, MethodDescriptor<?, ?> method)
throws StatusException {
if (authority == null) {
throw Status.UNAUTHENTICATED.withDescription("Channel has no authority").asException();
}
// Always use HTTPS, by definition.
final String scheme = "https";
final int defaultPort = 443;
String path = "/" + MethodDescriptor.extractFullServiceName(method.getFullMethodName());
URI uri;
try {
uri = new URI(scheme, authority, path, null, null);
} catch (URISyntaxException e) {
throw Status.UNAUTHENTICATED.withDescription("Unable to construct service URI for auth")
.withCause(e).asException();
}
// The default port must not be present. Alternative ports should be present.
if (uri.getPort() == defaultPort) {
uri = removePort(uri);
}
return uri;
}
示例3: serviceUri
import io.grpc.MethodDescriptor; //导入方法依赖的package包/类
/**
* Generate a JWT-specific service URI. The URI is simply an identifier with enough
* information for a service to know that the JWT was intended for it. The URI will
* commonly be verified with a simple string equality check.
*/
private URI serviceUri(Channel channel, MethodDescriptor<?, ?> method)
throws StatusException {
String authority = channel.authority();
if (authority == null) {
throw Status.UNAUTHENTICATED
.withDescription("Channel has no authority")
.asException();
}
// Always use HTTPS, by definition.
final String scheme = "https";
final int defaultPort = 443;
String path = "/" + MethodDescriptor.extractFullServiceName(method.getFullMethodName());
URI uri;
try {
uri = new URI(scheme, authority, path, null, null);
} catch (URISyntaxException e) {
throw Status.UNAUTHENTICATED
.withDescription("Unable to construct service URI for auth")
.withCause(e).asException();
}
// The default port must not be present. Alternative ports should be present.
if (uri.getPort() == defaultPort) {
uri = removePort(uri);
}
return uri;
}
示例4: of
import io.grpc.MethodDescriptor; //导入方法依赖的package包/类
static GrpcMethod of(MethodDescriptor<?, ?> method) {
String serviceName = MethodDescriptor.extractFullServiceName(method.getFullMethodName());
// Full method names are of the form: "full.serviceName/MethodName". We extract the last part.
String methodName = method.getFullMethodName().substring(serviceName.length() + 1);
return new GrpcMethod(serviceName, methodName, method.getType());
}
示例5: lookupMethod
import io.grpc.MethodDescriptor; //导入方法依赖的package包/类
/**
* Note: This does not actually honor the authority provided. It will, eventually in the future.
*/
@Override
@Nullable
public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
String serviceName = MethodDescriptor.extractFullServiceName(methodName);
if (serviceName == null) {
return null;
}
ServerServiceDefinition service = services.get(serviceName);
if (service == null) {
return null;
}
return service.getMethod(methodName);
}
示例6: FactoryImpl
import io.grpc.MethodDescriptor; //导入方法依赖的package包/类
/**
* Accepts a string in the format specified by the binary log spec.
*/
@VisibleForTesting
FactoryImpl(String configurationString) {
Preconditions.checkState(configurationString != null && configurationString.length() > 0);
BinaryLog globalLog = null;
Map<String, BinaryLog> perServiceLogs = new HashMap<String, BinaryLog>();
Map<String, BinaryLog> perMethodLogs = new HashMap<String, BinaryLog>();
for (String configuration : Splitter.on(',').split(configurationString)) {
Matcher configMatcher = configRe.matcher(configuration);
if (!configMatcher.matches()) {
throw new IllegalArgumentException("Bad input: " + configuration);
}
String methodOrSvc = configMatcher.group(1);
String binlogOptionStr = configMatcher.group(2);
BinaryLog binLog = createBinaryLog(binlogOptionStr);
if (binLog == null) {
continue;
}
if (methodOrSvc.equals("*")) {
if (globalLog != null) {
logger.log(Level.SEVERE, "Ignoring duplicate entry: " + configuration);
continue;
}
globalLog = binLog;
logger.info("Global binlog: " + globalLog);
} else if (isServiceGlob(methodOrSvc)) {
String service = MethodDescriptor.extractFullServiceName(methodOrSvc);
if (perServiceLogs.containsKey(service)) {
logger.log(Level.SEVERE, "Ignoring duplicate entry: " + configuration);
continue;
}
perServiceLogs.put(service, binLog);
logger.info(String.format("Service binlog: service=%s log=%s", service, binLog));
} else {
// assume fully qualified method name
if (perMethodLogs.containsKey(methodOrSvc)) {
logger.log(Level.SEVERE, "Ignoring duplicate entry: " + configuration);
continue;
}
perMethodLogs.put(methodOrSvc, binLog);
logger.info(String.format("Method binlog: method=%s log=%s", methodOrSvc, binLog));
}
}
this.globalLog = globalLog;
this.perServiceLogs = Collections.unmodifiableMap(perServiceLogs);
this.perMethodLogs = Collections.unmodifiableMap(perMethodLogs);
}