类 ReactorNetty2ResourceFactory

java.lang.Object
cn.taketoday.http.client.reactive.ReactorNetty2ResourceFactory
所有已实现的接口:
cn.taketoday.beans.factory.DisposableBean, cn.taketoday.beans.factory.InitializingBean

public class ReactorNetty2ResourceFactory extends Object implements cn.taketoday.beans.factory.InitializingBean, cn.taketoday.beans.factory.DisposableBean
Factory to manage Reactor Netty resources, i.e. LoopResources for event loop threads, and ConnectionProvider for the connection pool, within the lifecycle of a Infra ApplicationContext.

This factory implements InitializingBean and DisposableBean and is expected typically to be declared as a Infra-managed bean.

This class is based on ReactorResourceFactory.

从以下版本开始:
4.0
作者:
Harry Yang, Violeta Georgieva
  • 字段详细资料

    • useGlobalResources

      private boolean useGlobalResources
    • globalResourcesConsumer

      @Nullable private Consumer<reactor.netty5.http.HttpResources> globalResourcesConsumer
    • connectionProviderSupplier

      private Supplier<reactor.netty5.resources.ConnectionProvider> connectionProviderSupplier
    • connectionProvider

      @Nullable private reactor.netty5.resources.ConnectionProvider connectionProvider
    • loopResourcesSupplier

      private Supplier<reactor.netty5.resources.LoopResources> loopResourcesSupplier
    • loopResources

      @Nullable private reactor.netty5.resources.LoopResources loopResources
    • manageConnectionProvider

      private boolean manageConnectionProvider
    • manageLoopResources

      private boolean manageLoopResources
    • shutdownQuietPeriod

      private Duration shutdownQuietPeriod
    • shutdownTimeout

      private Duration shutdownTimeout
  • 构造器详细资料

    • ReactorNetty2ResourceFactory

      public ReactorNetty2ResourceFactory()
  • 方法详细资料

    • setUseGlobalResources

      public void setUseGlobalResources(boolean useGlobalResources)
      Whether to use global Reactor Netty resources via HttpResources.

      Default is "true" in which case this factory initializes and stops the global Reactor Netty resources within Infra ApplicationContext lifecycle. If set to "false" the factory manages its resources independent of the global ones.

      参数:
      useGlobalResources - whether to expose and manage the global resources
      另请参阅:
    • isUseGlobalResources

      public boolean isUseGlobalResources()
      Whether this factory exposes the global HttpResources holder.
    • addGlobalResourcesConsumer

      public void addGlobalResourcesConsumer(Consumer<reactor.netty5.http.HttpResources> consumer)
      Add a Consumer for configuring the global Reactor Netty resources on startup. When this option is used, setUseGlobalResources(boolean) is also enabled.
      参数:
      consumer - the consumer to apply
      另请参阅:
    • setConnectionProviderSupplier

      public void setConnectionProviderSupplier(Supplier<reactor.netty5.resources.ConnectionProvider> supplier)
      Use this when you don't want to participate in global resources and you want to customize the creation of the managed ConnectionProvider.

      By default, ConnectionProvider.elastic("http") is used.

      Note that this option is ignored if userGlobalResources=false or setConnectionProvider(ConnectionProvider) is set.

      参数:
      supplier - the supplier to use
    • setConnectionProvider

      public void setConnectionProvider(reactor.netty5.resources.ConnectionProvider connectionProvider)
      Use this when you want to provide an externally managed ConnectionProvider instance.
      参数:
      connectionProvider - the connection provider to use as is
    • getConnectionProvider

      public reactor.netty5.resources.ConnectionProvider getConnectionProvider()
      Return the configured ConnectionProvider.
    • setLoopResourcesSupplier

      public void setLoopResourcesSupplier(Supplier<reactor.netty5.resources.LoopResources> supplier)
      Use this when you don't want to participate in global resources and you want to customize the creation of the managed LoopResources.

      By default, LoopResources.create("reactor-http") is used.

      Note that this option is ignored if userGlobalResources=false or setLoopResources(LoopResources) is set.

      参数:
      supplier - the supplier to use
    • setLoopResources

      public void setLoopResources(reactor.netty5.resources.LoopResources loopResources)
      Use this option when you want to provide an externally managed LoopResources instance.
      参数:
      loopResources - the loop resources to use as is
    • getLoopResources

      public reactor.netty5.resources.LoopResources getLoopResources()
      Return the configured LoopResources.
    • setShutdownQuietPeriod

      public void setShutdownQuietPeriod(Duration shutdownQuietPeriod)
      Configure the amount of time we'll wait before shutting down resources. If a task is submitted during the shutdownQuietPeriod, it is guaranteed to be accepted and the shutdownQuietPeriod will start over.

      By default, this is set to LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIOD which is 2 seconds but can also be overridden with the system property ReactorNetty.SHUTDOWN_QUIET_PERIOD.

      另请参阅:
    • setShutdownTimeout

      public void setShutdownTimeout(Duration shutdownTimeout)
      Configure the maximum amount of time to wait until the disposal of the underlying resources regardless if a task was submitted during the shutdownQuietPeriod.

      By default, this is set to LoopResources.DEFAULT_SHUTDOWN_TIMEOUT which is 15 seconds but can also be overridden with the system property ReactorNetty.SHUTDOWN_TIMEOUT.

      另请参阅:
    • afterPropertiesSet

      public void afterPropertiesSet()
      指定者:
      afterPropertiesSet 在接口中 cn.taketoday.beans.factory.InitializingBean
    • destroy

      public void destroy()
      指定者:
      destroy 在接口中 cn.taketoday.beans.factory.DisposableBean