Search in sources :

Example 1 with WriteDemandEstimator

use of io.servicetalk.transport.netty.internal.WriteDemandEstimator in project servicetalk by apple.

the class NettyPipelinedConnectionTest method setUp.

@BeforeEach
void setUp() throws Exception {
    channel = new EmbeddedDuplexChannel(false);
    WriteDemandEstimator demandEstimator = mock(WriteDemandEstimator.class);
    writePublisher1 = new TestPublisher<>();
    writePublisher2 = new TestPublisher<>();
    when(demandEstimator.estimateRequestN(anyLong())).then(invocation1 -> MAX_VALUE);
    CloseHandler closeHandler = UNSUPPORTED_PROTOCOL_CLOSE_HANDLER;
    final DefaultNettyConnection<Integer, Integer> connection = DefaultNettyConnection.<Integer, Integer>initChannel(channel, DEFAULT_ALLOCATOR, immediate(), null, closeHandler, defaultFlushStrategy(), null, channel2 -> {
        channel2.pipeline().addLast(new ChannelInboundHandlerAdapter() {

            @Override
            public void channelRead(ChannelHandlerContext ctx, Object msg) {
                ctx.fireChannelRead(msg);
                closeHandler.protocolPayloadEndInbound(ctx);
            }
        });
    }, defaultStrategy(), mock(Protocol.class), NoopConnectionObserver.INSTANCE, true, __ -> false).toFuture().get();
    requester = new NettyPipelinedConnection<>(connection, 8);
}
Also used : EmbeddedDuplexChannel(io.servicetalk.transport.netty.internal.EmbeddedDuplexChannel) CloseHandler(io.servicetalk.transport.netty.internal.CloseHandler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Protocol(io.servicetalk.transport.api.ConnectionInfo.Protocol) WriteDemandEstimator(io.servicetalk.transport.netty.internal.WriteDemandEstimator) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)1 Protocol (io.servicetalk.transport.api.ConnectionInfo.Protocol)1 CloseHandler (io.servicetalk.transport.netty.internal.CloseHandler)1 EmbeddedDuplexChannel (io.servicetalk.transport.netty.internal.EmbeddedDuplexChannel)1 WriteDemandEstimator (io.servicetalk.transport.netty.internal.WriteDemandEstimator)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1