Class HttpResources

java.lang.Object
reactor.netty.tcp.TcpResources
reactor.netty.http.HttpResources
All Implemented Interfaces:
Disposable, ConnectionProvider, LoopResources

public final class HttpResources extends TcpResources
Hold the default HTTP/1.x resources.
Since:
0.6
Author:
Stephane Maldini
  • Method Details

    • disposeLoopsAndConnections

      public static void disposeLoopsAndConnections()
      Shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones. This method is NOT blocking. It is implemented as fire-and-forget. Use disposeLoopsAndConnectionsLater() when you need to observe the final status of the operation, combined with Mono.block() if you need to synchronously wait for the underlying resources to be disposed.
    • disposeLoopsAndConnectionsLater

      public static Mono<Void> disposeLoopsAndConnectionsLater()
      Prepare to shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returned Mono is subscribed to. The quiet period will be 2s and the timeout will be 15s
      Returns:
      a Mono triggering the disposeLoopsAndConnections() when subscribed to.
    • disposeLoopsAndConnectionsLater

      public static Mono<Void> disposeLoopsAndConnectionsLater(Duration quietPeriod, Duration timeout)
      Prepare to shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returned Mono is subscribed to. It is guaranteed that the disposal of the underlying LoopResources will not happen before quietPeriod is over. If a task is submitted during the quietPeriod, it is guaranteed to be accepted and the quietPeriod will start over.
      Parameters:
      quietPeriod - the quiet period as described above
      timeout - the maximum amount of time to wait until the disposal of the underlying LoopResources regardless if a task was submitted during the quiet period
      Returns:
      a Mono triggering the disposeLoopsAndConnections() when subscribed to.
      Since:
      0.9.3
    • get

      public static HttpResources get()
      Return the global HTTP resources for event loops and pooling.
      Returns:
      the global HTTP resources for event loops and pooling
    • reset

      public static HttpResources reset()
      Reset http resources to default and return its instance.
      Returns:
      the global HTTP resources
    • set

      public static HttpResources set(ConnectionProvider provider)
      Update pooling resources and return the global HTTP/1.x resources. Note: The previous ConnectionProvider will be disposed.
      Parameters:
      provider - a new ConnectionProvider to replace the current
      Returns:
      the global HTTP/1.x resources
    • set

      public static HttpResources set(LoopResources loops)
      Update event loops resources and return the global HTTP/1.x resources. Note: The previous LoopResources will be disposed.
      Parameters:
      loops - a new LoopResources to replace the current
      Returns:
      the global HTTP/1.x resources
    • disposeWhen

      public void disposeWhen(SocketAddress remoteAddress)
      Description copied from class: TcpResources
      Dispose all connection pools for the specified remote address.

      As opposed to TcpResources.dispose(), this method delegates to the underlying connection provider. It has a global effect and removes all connection pools for this remote address from the global TCP resources (making it closer to TcpResources.disposeLoopsAndConnections() than to TcpResources.dispose()).

      Specified by:
      disposeWhen in interface ConnectionProvider
      Overrides:
      disposeWhen in class TcpResources
      Parameters:
      remoteAddress - the remote address
    • getOrCreateDefaultResolver

      public AddressResolverGroup<?> getOrCreateDefaultResolver()
      Description copied from class: TcpResources
      Safely checks whether a name resolver exists and proceed with a creation if it does not exist. The name resolver uses as an event loop group the LoopResources that are configured. Guarantees that always one and the same instance is returned for a given LoopResources and if the LoopResources is updated the name resolver is also updated.
      Overrides:
      getOrCreateDefaultResolver in class TcpResources
      Returns:
      an existing or new AddressResolverGroup
    • getOrCreateHttp2ConnectionProvider

      public ConnectionProvider getOrCreateHttp2ConnectionProvider(Function<ConnectionProvider,ConnectionProvider> create)
      Safely checks whether a ConnectionProvider for HTTP/2 traffic exists and proceed with a creation if it does not exist.
      Parameters:
      create - the create function provides the current ConnectionProvider for HTTP/1.1 traffic in case some ConnectionProvider configuration is needed.
      Returns:
      an existing or new ConnectionProvider for HTTP/2 traffic
      Since:
      1.0.16
    • getOrCreateHttp3ConnectionProvider

      public ConnectionProvider getOrCreateHttp3ConnectionProvider(Function<ConnectionProvider,ConnectionProvider> create)
      Safely checks whether a ConnectionProvider for HTTP/3 traffic exists and proceed with a creation if it does not exist.
      Parameters:
      create - the create function provides the current ConnectionProvider for HTTP/1.1 traffic in case some ConnectionProvider configuration is needed.
      Returns:
      an existing or new ConnectionProvider for HTTP/3 traffic
      Since:
      1.2.0