io.grpc.util.MutableHandlerRegistry Java Examples
The following examples show how to use
io.grpc.util.MutableHandlerRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrpcServerRule.java From grpc-java with Apache License 2.0 | 6 votes |
/** * Before the test has started, create the server and channel. */ @Override protected void before() throws Throwable { serverName = UUID.randomUUID().toString(); serviceRegistry = new MutableHandlerRegistry(); InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName) .fallbackHandlerRegistry(serviceRegistry); if (useDirectExecutor) { serverBuilder.directExecutor(); } server = serverBuilder.build().start(); InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName); if (useDirectExecutor) { channelBuilder.directExecutor(); } channel = channelBuilder.build(); }
Example #2
Source File: GrpcServerRule.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
/** * Before the test has started, create the server and channel. */ @Override protected void before() throws Throwable { serverName = UUID.randomUUID().toString(); serviceRegistry = new MutableHandlerRegistry(); InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName) .fallbackHandlerRegistry(serviceRegistry); if (useDirectExecutor) { serverBuilder.directExecutor(); } server = serverBuilder.build().start(); InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName); if (useDirectExecutor) { channelBuilder.directExecutor(); } channel = channelBuilder.build(); }
Example #3
Source File: GrpcServerExtension.java From jetcd with Apache License 2.0 | 6 votes |
/** * Before the test has started, create the server and channel. */ @Override public void beforeEach(ExtensionContext context) throws Exception { serverName = UUID.randomUUID().toString(); serviceRegistry = new MutableHandlerRegistry(); InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName) .fallbackHandlerRegistry(serviceRegistry); if (useDirectExecutor) { serverBuilder.directExecutor(); } server = serverBuilder.build().start(); InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName); if (useDirectExecutor) { channelBuilder.directExecutor(); } channel = channelBuilder.build(); }
Example #4
Source File: MaintenanceUnitTest.java From jetcd with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() throws IOException, URISyntaxException { observerQueue = new LinkedBlockingQueue<>(); executor = Executors.newFixedThreadPool(2); serviceRegistry = new MutableHandlerRegistry(); serviceRegistry.addService(new MaintenanceImplBase() { @Override public void snapshot(SnapshotRequest request, StreamObserver<SnapshotResponse> observer) { try { observerQueue.put(observer); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); fakeServer = NettyServerBuilder.forPort(TestUtil.findNextAvailablePort()).fallbackHandlerRegistry(serviceRegistry) .directExecutor().build().start(); client = Client.builder().endpoints(new URI("http://127.0.0.1:" + fakeServer.getPort())).build(); maintenance = client.getMaintenanceClient(); }
Example #5
Source File: NettyGrpcServerRule.java From grpc-java-contrib with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Before the test has started, create the server and channel. */ @Override protected void before() throws Throwable { serviceRegistry = new MutableHandlerRegistry(); NettyServerBuilder serverBuilder = NettyServerBuilder .forPort(0) .fallbackHandlerRegistry(serviceRegistry); if (useDirectExecutor) { serverBuilder.directExecutor(); } configureServerBuilder.accept(serverBuilder); server = serverBuilder.build().start(); port = server.getPort(); NettyChannelBuilder channelBuilder = NettyChannelBuilder.forAddress("localhost", port).usePlaintext(true); configureChannelBuilder.accept(channelBuilder); channel = channelBuilder.build(); }
Example #6
Source File: GrpcRaftRpcFactory.java From sofa-jraft with Apache License 2.0 | 5 votes |
@Override public RpcServer createRpcServer(final Endpoint endpoint, final ConfigHelper<RpcServer> helper) { final int port = Requires.requireNonNull(endpoint, "endpoint").getPort(); Requires.requireTrue(port > 0 && port < 0xFFFF, "port out of range:" + port); final MutableHandlerRegistry handlerRegistry = new MutableHandlerRegistry(); final Server server = ServerBuilder.forPort(port) // .fallbackHandlerRegistry(handlerRegistry) // .directExecutor() // .build(); final RpcServer rpcServer = new GrpcServer(server, handlerRegistry, this.parserClasses, getMarshallerRegistry()); if (helper != null) { helper.config(rpcServer); } return rpcServer; }
Example #7
Source File: GrpcServer.java From sofa-jraft with Apache License 2.0 | 5 votes |
public GrpcServer(Server server, MutableHandlerRegistry handlerRegistry, Map<String, Message> parserClasses, MarshallerRegistry marshallerRegistry) { this.server = server; this.handlerRegistry = handlerRegistry; this.parserClasses = parserClasses; this.marshallerRegistry = marshallerRegistry; registerDefaultServerInterceptor(); }
Example #8
Source File: NettyGrpcServerRule.java From java-control-plane with Apache License 2.0 | 5 votes |
/** * Before the test has started, create the server and channel. */ @Override protected void before() throws Throwable { serviceRegistry = new MutableHandlerRegistry(); NettyServerBuilder serverBuilder = NettyServerBuilder.forPort(getAvailablePort()) .fallbackHandlerRegistry(serviceRegistry); configureServerBuilder(serverBuilder); server = serverBuilder.build().start(); logger.info("Started gRPC server on port: " + server.getPort()); }
Example #9
Source File: HandlerRegistryBenchmark.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** * Set up the registry. */ @Setup(Level.Trial) public void setup() throws Exception { registry = new MutableHandlerRegistry(); fullMethodNames = new ArrayList<>(serviceCount * methodCountPerService); for (int serviceIndex = 0; serviceIndex < serviceCount; ++serviceIndex) { String serviceName = randomString(); ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition.builder(serviceName); for (int methodIndex = 0; methodIndex < methodCountPerService; ++methodIndex) { String methodName = randomString(); MethodDescriptor<Void, Void> methodDescriptor = MethodDescriptor.<Void, Void>newBuilder() .setType(MethodDescriptor.MethodType.UNKNOWN) .setFullMethodName(MethodDescriptor.generateFullMethodName(serviceName, methodName)) .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) .build(); serviceBuilder.addMethod(methodDescriptor, new ServerCallHandler<Void, Void>() { @Override public Listener<Void> startCall(ServerCall<Void, Void> call, Metadata headers) { return null; } }); fullMethodNames.add(methodDescriptor.getFullMethodName()); } registry.addService(serviceBuilder.build()); } }
Example #10
Source File: TracedService.java From java-grpc with Apache License 2.0 | 4 votes |
static void addGeeterService(MutableHandlerRegistry registry) { registry.addService(new GreeterImpl()); }
Example #11
Source File: TracedService.java From java-grpc with Apache License 2.0 | 4 votes |
static void addGeeterService(MutableHandlerRegistry registry, ServerInterceptor... interceptors) { registry.addService(ServerInterceptors.intercept(new GreeterImpl(), interceptors)); }
Example #12
Source File: GrpcServer.java From sofa-jraft with Apache License 2.0 | 4 votes |
public MutableHandlerRegistry getHandlerRegistry() { return handlerRegistry; }
Example #13
Source File: NettyGrpcServerRule.java From grpc-java-contrib with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns the service registry for this service. The registry is used to add service instances * (e.g. {@link io.grpc.BindableService} or {@link io.grpc.ServerServiceDefinition} to the server. */ public final MutableHandlerRegistry getServiceRegistry() { return serviceRegistry; }
Example #14
Source File: NettyGrpcServerRule.java From java-control-plane with Apache License 2.0 | 2 votes |
/** * Returns the service registry for this service. The registry is used to add service instances * (e.g. {@link BindableService} or {@link ServerServiceDefinition} to the server. */ public final MutableHandlerRegistry getServiceRegistry() { return serviceRegistry; }
Example #15
Source File: GrpcServerExtension.java From jetcd with Apache License 2.0 | 2 votes |
/** * Returns the service registry for this service. The registry is used to add service instances * (e.g. {@link BindableService} or {@link ServerServiceDefinition} to the server. */ public final MutableHandlerRegistry getServiceRegistry() { return serviceRegistry; }
Example #16
Source File: GrpcServerRule.java From grpc-java with Apache License 2.0 | 2 votes |
/** * Returns the service registry for this service. The registry is used to add service instances * (e.g. {@link BindableService} or {@link ServerServiceDefinition} to the server. */ public final MutableHandlerRegistry getServiceRegistry() { return serviceRegistry; }
Example #17
Source File: GrpcServerRule.java From grpc-nebula-java with Apache License 2.0 | 2 votes |
/** * Returns the service registry for this service. The registry is used to add service instances * (e.g. {@link BindableService} or {@link ServerServiceDefinition} to the server. */ public final MutableHandlerRegistry getServiceRegistry() { return serviceRegistry; }