Package reactor.netty

Class ReactorNetty

java.lang.Object
reactor.netty.ReactorNetty

public final class ReactorNetty extends Object
Internal helpers for reactor-netty contracts.
Author:
Stephane Maldini
  • Field Details

    • IO_WORKER_COUNT

      public static final String IO_WORKER_COUNT
      Default worker thread count, fallback to available processor (but with a minimum value of 4).
      See Also:
    • IO_SELECT_COUNT

      public static final String IO_SELECT_COUNT
      Default selector thread count, fallback to -1 (no selector thread)

      Note: In most use cases using a worker thread also as a selector thread works well. A possible use case for specifying a separate selector thread might be when the worker threads are too busy and connections cannot be accepted fast enough.

      Note: Although more than 1 can be configured as a selector thread count, in reality only 1 thread will be used as a selector thread.

      See Also:
    • UDP_IO_THREAD_COUNT

      public static final String UDP_IO_THREAD_COUNT
      Default worker thread count for UDP, fallback to available processor (but with a minimum value of 4).
      See Also:
    • SHUTDOWN_QUIET_PERIOD

      public static final String SHUTDOWN_QUIET_PERIOD
      Default quiet period that guarantees that the disposal of the underlying LoopResources will not happen, fallback to 2 seconds.
      See Also:
    • SHUTDOWN_TIMEOUT

      public static final String SHUTDOWN_TIMEOUT
      Default maximum amount of time to wait until the disposal of the underlying LoopResources regardless if a task was submitted during the quiet period, fallback to 15 seconds.
      See Also:
    • NATIVE

      public static final String NATIVE
      Default value whether the native transport (epoll, io_uring, kqueue) will be preferred, fallback it will be preferred when available.

      Note: On Linux, Epoll will be preferred by default. If IO_Uring needs to be configured, a dependency to io.netty:netty-transport-native-io_uring has to be added.

      See Also:
    • POOL_MAX_CONNECTIONS

      public static final String POOL_MAX_CONNECTIONS
      Default max connections. Fallback to 2 * available number of processors (but with a minimum value of 16)
      See Also:
    • POOL_ACQUIRE_TIMEOUT

      public static final String POOL_ACQUIRE_TIMEOUT
      Default acquisition timeout (milliseconds) before error. If -1 will never wait to acquire before opening a new connection in an unbounded fashion. Fallback 45 seconds
      See Also:
    • POOL_MAX_IDLE_TIME

      public static final String POOL_MAX_IDLE_TIME
      Default max idle time, fallback - max idle time is not specified.

      Note: This configuration is not applicable for TcpClient. A TCP connection is always closed and never returned to the pool.

      See Also:
    • POOL_MAX_LIFE_TIME

      public static final String POOL_MAX_LIFE_TIME
      Default max life time, fallback - max life time is not specified.

      Note: This configuration is not applicable for TcpClient. A TCP connection is always closed and never returned to the pool.

      See Also:
    • POOL_LEASING_STRATEGY

      public static final String POOL_LEASING_STRATEGY
      Default leasing strategy (fifo, lifo), fallback to fifo.
      • fifo - The connection selection is first in, first out
      • lifo - The connection selection is last in, first out

      Note: This configuration is not applicable for TcpClient. A TCP connection is always closed and never returned to the pool.

      See Also:
    • POOL_GET_PERMITS_SAMPLING_RATE

      public static final String POOL_GET_PERMITS_SAMPLING_RATE
      Default getPermitsSamplingRate (between 0d and 1d (percentage)) to be used with a SamplingAllocationStrategy. This strategy wraps a sizeBetween AllocationStrategy and samples calls to AllocationStrategy.getPermits(int). Fallback - sampling is not enabled.
      See Also:
    • POOL_RETURN_PERMITS_SAMPLING_RATE

      public static final String POOL_RETURN_PERMITS_SAMPLING_RATE
      Default returnPermitsSamplingRate (between 0d and 1d (percentage)) to be used with a SamplingAllocationStrategy. This strategy wraps a sizeBetween AllocationStrategy and samples calls to AllocationStrategy.returnPermits(int). Fallback - sampling is not enabled.
      See Also:
    • SSL_HANDSHAKE_TIMEOUT

      public static final String SSL_HANDSHAKE_TIMEOUT
      Default SSL handshake timeout (milliseconds), fallback to 10 seconds.
      See Also:
    • SSL_CLIENT_DEBUG

      public static final String SSL_CLIENT_DEBUG
      Default value whether the SSL debugging on the client side will be enabled/disabled, fallback to SSL debugging disabled.
      See Also:
    • SSL_SERVER_DEBUG

      public static final String SSL_SERVER_DEBUG
      Default value whether the SSL debugging on the server side will be enabled/disabled, fallback to SSL debugging disabled.
      See Also:
    • ACCESS_LOG_ENABLED

      public static final String ACCESS_LOG_ENABLED
      Specifies whether the Http Server access log will be enabled. By default, it is disabled.
      See Also:
    • ERROR_LOG_ENABLED

      public static final String ERROR_LOG_ENABLED
      Specifies whether the Http Server error log will be enabled. By default, it is disabled.
      See Also:
    • ZONE_ID_SYSTEM

      public static final ZoneId ZONE_ID_SYSTEM
      Specifies the zone id used by the access log.
    • REACTOR_NETTY_SEND_MAX_PREFETCH_SIZE

      public static final String REACTOR_NETTY_SEND_MAX_PREFETCH_SIZE
      Default prefetch size (Subscription.request(long)) for data stream Publisher, fallback to 128.
      See Also:
    • PREDICATE_GROUP_FLUSH

      public static final Predicate<ByteBuf> PREDICATE_GROUP_FLUSH
  • Method Details

    • safeRelease

      public static void safeRelease(Object msg)
      Try to call ReferenceCounted.release() if the specified message implements ReferenceCounted. If the specified message doesn't implement ReferenceCounted or it is already released, this method does nothing.
    • format

      public static String format(Channel channel, String msg)
      Append channel ID to a log message for correlated traces.
      Parameters:
      channel - current channel associated with the msg
      msg - the log msg
      Returns:
      a formatted msg
    • toPrettyHexDump

      @Deprecated public static String toPrettyHexDump(Object msg)
      Deprecated.
      as of 1.1.0. This will be removed in 2.0.0 as the functionality is not used anymore.
      Pretty hex dump will be returned when the object is ByteBuf or ByteBufHolder.
    • getChannelContext

      public static @Nullable ContextView getChannelContext(Channel channel)
      Returns ContextView from the channel attributes when exists otherwise returns null.
      Parameters:
      channel - the channel
      Returns:
      ContextView from the channel attributes when exists otherwise returns null
      Since:
      1.0.26
    • setChannelContext

      public static void setChannelContext(Channel channel, @Nullable ContextView contextView)
      Adds ContextView to the channel attributes. When null is provided, the channel attribute's value will be deleted.
      Parameters:
      channel - the channel
      contextView - ContextView that will be added to the channel attributes
      Since:
      1.0.26
    • wrapException

      public static RuntimeException wrapException(Throwable throwable)
      Wrap possibly fatal or singleton exception into a new exception instance in order to propagate in reactor flows without side effect.
      Returns:
      a wrapped RuntimeException