Package io.micronaut.http.client.netty
Class ConnectTTLHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- io.micronaut.http.client.netty.ConnectTTLHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class ConnectTTLHandler extends io.netty.channel.ChannelDuplexHandlerA handler that will close channels after they have reached their time-to-live, regardless of usage. channels that are in use will be closed when they are next released to the underlying connection pool.
-
-
Field Summary
Fields Modifier and Type Field Description static io.netty.util.AttributeKey<java.lang.Boolean>RELEASE_CHANNEL
-
Constructor Summary
Constructors Constructor Description ConnectTTLHandler(java.lang.Long connectionTtlMillis)Construct ConnectTTLHandler for given arguments.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx)Will schedule a task when the handler added.voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx)Will cancel the scheduled tasks when handler removed.static booleanisChannelExpired(io.netty.channel.Channel channel)Indicates whether the channels connection ttl has expired.-
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read, write
-
-
-
-
Method Detail
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.ExceptionWill schedule a task when the handler added.- Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter- Parameters:
ctx- The context to use- Throws:
java.lang.Exception
-
handlerRemoved
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
Will cancel the scheduled tasks when handler removed.- Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter- Parameters:
ctx- The context to use
-
isChannelExpired
public static boolean isChannelExpired(io.netty.channel.Channel channel)
Indicates whether the channels connection ttl has expired.- Parameters:
channel- The channel to check- Returns:
- true if the channels ttl has expired
-
-