use of io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory in project servicetalk by apple.
the class SingleRequestOrResponseApiTest method setUp.
private void setUp(boolean streamingService, boolean streamingClient) throws Exception {
this.streamingService = streamingService;
this.streamingClient = streamingClient;
serverContext = GrpcServers.forAddress(localAddress(0)).listenAndAwait(streamingService ? new ServiceFactory(new TesterServiceImpl()) : new ServiceFactory(new BlockingTesterServiceImpl()));
clientBuilder = GrpcClients.forAddress(serverHostAndPort(serverContext)).initializeHttp(builder -> builder.appendClientFilter(origin -> new StreamingHttpClientFilter(origin) {
@Override
protected Single<StreamingHttpResponse> request(StreamingHttpRequester delegate, StreamingHttpRequest request) {
// and generates requested number of response items:
return defer(() -> {
request.requestTarget(BlockingTestResponseStreamRpc.PATH);
return delegate.request(request).shareContextOnSubscribe();
});
}
}));
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory in project servicetalk by apple.
the class ErrorHandlingTest method setupForServiceSecondOperatorThrows.
private ServiceFactory setupForServiceSecondOperatorThrows(final Throwable toThrow) {
final TesterService service = mockTesterService();
setupForServiceSecondOperatorThrows(service, toThrow);
return new ServiceFactory(service);
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory in project servicetalk by apple.
the class ExecutionStrategyTest method setUp.
private void setUp(ContextExecutionStrategy contextStrategy, RouteExecutionStrategy routeStrategy, RouteApi routeApi) throws Exception {
this.contextStrategy = contextStrategy;
this.routeStrategy = routeStrategy;
this.routeApi = routeApi;
GrpcServerBuilder builder = GrpcServers.forAddress(localAddress(0));
contextStrategy.configureContextExecutionStrategy(builder);
ServiceFactory serviceFactory = routeStrategy.getServiceFactory();
serverContext = builder.listenAndAwait(serviceFactory);
client = GrpcClients.forAddress(serverHostAndPort(serverContext)).initializeHttp(b -> b.executionStrategy(HttpExecutionStrategies.offloadNever())).buildBlocking(new ClientFactory());
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory in project servicetalk by apple.
the class GrpcServiceContextProtocolTest method setUp.
private void setUp(HttpProtocolVersion httpProtocol, boolean streamingService) throws Exception {
expectedValue = "gRPC over " + httpProtocol;
serverContext = GrpcServers.forAddress(localAddress(0)).initializeHttp(builder -> builder.protocols(protocolConfig(httpProtocol))).listenAndAwait(streamingService ? new ServiceFactory(new TesterServiceImpl()) : new ServiceFactory(new BlockingTesterServiceImpl()));
client = GrpcClients.forAddress(serverHostAndPort(serverContext)).initializeHttp(builder -> builder.protocols(protocolConfig(httpProtocol))).buildBlocking(new ClientFactory());
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory in project servicetalk by apple.
the class KeepAliveTest method setUp.
private void setUp(final boolean keepAlivesFromClient, final Duration keepAliveIdleFor, final Duration idleTimeout) throws Exception {
this.idleTimeoutMillis = idleTimeout.toMillis();
GrpcServerBuilder serverBuilder = forAddress(localAddress(0)).initializeHttp(builder -> {
builder.executor(SERVER_CTX.executor()).ioExecutor(SERVER_CTX.ioExecutor()).executionStrategy(defaultStrategy());
if (!keepAlivesFromClient) {
builder.protocols(h2Config(keepAliveIdleFor));
} else {
builder.socketOption(IDLE_TIMEOUT, idleTimeoutMillis).protocols(h2Config(null));
}
});
ctx = serverBuilder.listenAndAwait(new ServiceFactory(new InfiniteStreamsService()));
GrpcClientBuilder<HostAndPort, InetSocketAddress> clientBuilder = GrpcClients.forAddress(serverHostAndPort(ctx)).initializeHttp(builder -> builder.executor(CLIENT_CTX.executor()).ioExecutor(CLIENT_CTX.ioExecutor()).executionStrategy(defaultStrategy()));
if (keepAlivesFromClient) {
clientBuilder.initializeHttp(builder -> builder.protocols(h2Config(keepAliveIdleFor)));
} else {
clientBuilder.initializeHttp(builder -> builder.socketOption(IDLE_TIMEOUT, idleTimeoutMillis).protocols(h2Config(null)));
}
client = clientBuilder.build(new ClientFactory());
}
Aggregations