use of io.servicetalk.http.api.HttpApiConversions.ServiceAdapterHolder in project servicetalk by apple.
the class BlockingStreamingToStreamingServiceTest method invokeService.
private List<Object> invokeService(BlockingStreamingHttpService syncService, StreamingHttpRequest request) throws Exception {
ServiceAdapterHolder holder = toStreamingHttpService(syncService, offloadNone());
Collection<Object> responseCollection = invokeService(holder.serviceInvocationStrategy(), executorExtension.executor(), request, req -> holder.adaptor().handle(mockCtx, req, reqRespFactory).flatMapPublisher(response -> Publisher.<Object>from(response).concat(response.messageBody())), (t, e) -> failed(t)).toFuture().get();
return new ArrayList<>(responseCollection);
}
use of io.servicetalk.http.api.HttpApiConversions.ServiceAdapterHolder in project servicetalk by apple.
the class GrpcRouter method populateRoutes.
private static void populateRoutes(final GrpcExecutionContext executionContext, final Map<String, StreamingHttpService> allRoutes, final Map<String, RouteProvider> routes, final CompositeCloseable closeable, final Map<String, GrpcExecutionStrategy> executionStrategies) {
for (Map.Entry<String, RouteProvider> entry : routes.entrySet()) {
final String path = entry.getKey();
final ServiceAdapterHolder adapterHolder = entry.getValue().buildRoute(executionContext);
final StreamingHttpService route = closeable.append(adapterHolder.adaptor());
final GrpcExecutionStrategy routeStrategy = executionStrategies.getOrDefault(path, null);
final HttpExecutionStrategy missing = null == routeStrategy ? HttpExecutionStrategies.offloadNone() : executionContext.executionStrategy().missing(routeStrategy);
verifyNoOverrides(allRoutes.put(path, null != routeStrategy && missing.isRequestResponseOffloaded() ? StreamingHttpServiceToOffloadedStreamingHttpService.offloadService(adapterHolder.serviceInvocationStrategy(), executionContext.executor(), IoThreadFactory.IoThread::currentThreadIsIoThread, route) : route), path, emptyMap());
LOGGER.debug("route strategy for path={} : ctx={} route={} → using={}", path, executionContext.executionStrategy(), routeStrategy, missing);
}
}
Aggregations