io.reactivex.netty.pipeline.ReadTimeoutPipelineConfigurator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rx-netty Show documentation
Show all versions of rx-netty Show documentation
rx-netty developed by Netflix
/*
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.reactivex.netty.pipeline;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.util.concurrent.EventExecutor;
import io.reactivex.netty.protocol.http.client.ClientRequestResponseConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
/**
* An implementation of {@link PipelineConfigurator} to configure a read time handler.
* A read timeout is defined as lack of bytes read from the channel over the specified period.
* This configurator, adds the {@link ReadTimeoutHandler} after every write, if not present.
*
* Reusable connections and timeout
*
* In cases where the connection is reused (like HTTP persistent connections), it is the responsibility of the protocol
* to remove this timeout handler, for not being timed out (resulting in connection close) due to inactivity when the
* connection is not in use.
*
* @see ReadTimeoutHandler
*
* @author Nitesh Kant
*/
@ChannelHandler.Sharable
public class ReadTimeoutPipelineConfigurator implements PipelineConfigurator
© 2015 - 2024 Weber Informatics LLC | Privacy Policy