Search in sources :

Example 1 with Http1to2Framing

use of com.accenture.trac.gateway.proxy.http.Http1to2Framing in project tracdap by finos.

the class GrpcProxyBuilder method initChannel.

@Override
protected void initChannel(Channel channel) {
    log.info("Init gRPC proxy channel");
    var pipeline = channel.pipeline();
    pipeline.addLast("OBJECT_LOGGER", new ObjectLogger());
    var initialSettings = new Http2Settings().maxFrameSize(16 * 1024);
    log.info(initialSettings.toString());
    var http2Codec = Http2FrameCodecBuilder.forClient().frameLogger(new Http2FrameLogger(LogLevel.INFO)).initialSettings(initialSettings).autoAckSettingsFrame(true).autoAckPingFrame(true).build();
    pipeline.addLast(HTTP2_FRAME_CODEC, http2Codec);
    pipeline.addLast(GRPC_PROXY_HANDLER, new GrpcProxy());
    pipeline.addLast(GRPC_WEB_PROXY_HANDLER, new GrpcWebProxy());
    if (sourceHttpVersion == 1) {
        pipeline.addLast(HTTP_1_TO_2_FRAMING, new Http1to2Framing(routeConfig));
        pipeline.addLast(HTTP_1_ROUTER_LINK, routerLink);
    } else if (sourceHttpVersion == 2) {
        throw new RuntimeException("HTTP/2 source connection for REST not implemented yet");
    } else
        throw new EUnexpected();
}
Also used : Http1to2Framing(com.accenture.trac.gateway.proxy.http.Http1to2Framing) EUnexpected(com.accenture.trac.common.exception.EUnexpected)

Example 2 with Http1to2Framing

use of com.accenture.trac.gateway.proxy.http.Http1to2Framing in project tracdap by finos.

the class RestApiProxyBuilder method initChannel.

@Override
protected void initChannel(Channel channel) throws Exception {
    log.info("Init REST proxy channel");
    var pipeline = channel.pipeline();
    // HTTP/2 Codec, required for channels using the HTTP frame objects
    var initialSettings = new Http2Settings().maxFrameSize(16 * 1024);
    var http2Codec = Http2FrameCodecBuilder.forClient().frameLogger(new Http2FrameLogger(LogLevel.INFO)).initialSettings(initialSettings).autoAckSettingsFrame(true).autoAckPingFrame(true).build();
    pipeline.addLast(http2Codec);
    // REST proxy
    // TODO: Build this after reading service config and pass it in
    var restApiConfig = routeConfig.getRestMethods();
    var grpcHost = routeConfig.getConfig().getTarget().getHost();
    var grpcPort = (short) routeConfig.getConfig().getTarget().getPort();
    var restApiProxy = new RestApiProxy(grpcHost, grpcPort, restApiConfig, executor);
    pipeline.addLast(restApiProxy);
    if (sourceHttpVersion == 1) {
        pipeline.addLast(new Http1to2Framing(routeConfig.getConfig()));
        pipeline.addLast(routerLink);
    } else if (sourceHttpVersion == 2) {
        throw new RuntimeException("HTTP/2 source connection for REST not implemented yet");
    } else
        throw new EUnexpected();
}
Also used : Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger) Http2Settings(io.netty.handler.codec.http2.Http2Settings) Http1to2Framing(com.accenture.trac.gateway.proxy.http.Http1to2Framing) EUnexpected(com.accenture.trac.common.exception.EUnexpected)

Aggregations

EUnexpected (com.accenture.trac.common.exception.EUnexpected)2 Http1to2Framing (com.accenture.trac.gateway.proxy.http.Http1to2Framing)2 Http2FrameLogger (io.netty.handler.codec.http2.Http2FrameLogger)1 Http2Settings (io.netty.handler.codec.http2.Http2Settings)1