core: make InternalHandlerRegistry a HandlerRegistry

This commit is contained in:
Carl Mastrangelo 2018-06-29 13:01:25 -07:00 committed by GitHub
parent b2dd6ae7f0
commit 39d2dd0eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -65,8 +65,9 @@ public abstract class AbstractServerImplBuilder<T extends AbstractServerImplBuil
}
@Override
public ServerMethodDefinition<?, ?> lookupMethod(String methodName,
@Nullable String authority) {
@Nullable
public ServerMethodDefinition<?, ?> lookupMethod(
String methodName, @Nullable String authority) {
return null;
}
};

View File

@ -16,6 +16,7 @@
package io.grpc.internal;
import io.grpc.HandlerRegistry;
import io.grpc.ServerMethodDefinition;
import io.grpc.ServerServiceDefinition;
import java.util.ArrayList;
@ -26,7 +27,7 @@ import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
final class InternalHandlerRegistry {
final class InternalHandlerRegistry extends HandlerRegistry {
private final List<ServerServiceDefinition> services;
private final Map<String, ServerMethodDefinition<?, ?>> methods;
@ -40,16 +41,19 @@ final class InternalHandlerRegistry {
/**
* Returns the service definitions in this registry.
*/
@Override
public List<ServerServiceDefinition> getServices() {
return services;
}
@Nullable
ServerMethodDefinition<?, ?> lookupMethod(String methodName) {
@Override
public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
// TODO (carl-mastrangelo): honor authority header.
return methods.get(methodName);
}
static class Builder {
static final class Builder {
// Store per-service first, to make sure services are added/replaced atomically.
private final HashMap<String, ServerServiceDefinition> services =

View File

@ -83,7 +83,7 @@ public final class ServerImpl extends io.grpc.Server implements Instrumented<Ser
private final ObjectPool<? extends Executor> executorPool;
/** Executor for application processing. Safe to read after {@link #start()}. */
private Executor executor;
private final InternalHandlerRegistry registry;
private final HandlerRegistry registry;
private final HandlerRegistry fallbackRegistry;
private final List<ServerTransportFilter> transportFilters;
// This is iterated on a per-call basis. Use an array instead of a Collection to avoid iterator