Polishing
This commit is contained in:
parent
8cf70fe509
commit
b6f502db4e
|
|
@ -50,11 +50,11 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
@SuppressWarnings("deprecation")
|
||||
private Supplier<ConnectionProvider> connectionProviderSupplier = () -> ConnectionProvider.fixed("webflux", 500);
|
||||
|
||||
private Supplier<LoopResources> loopResourcesSupplier = () -> LoopResources.create("webflux-http");
|
||||
|
||||
@Nullable
|
||||
private ConnectionProvider connectionProvider;
|
||||
|
||||
private Supplier<LoopResources> loopResourcesSupplier = () -> LoopResources.create("webflux-http");
|
||||
|
||||
@Nullable
|
||||
private LoopResources loopResources;
|
||||
|
||||
|
|
@ -88,29 +88,6 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
return this.useGlobalResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the amount of time we'll wait before shutting down resources. If a task is
|
||||
* submitted during the {@code quietPeriod}, it is guaranteed to be accepted and the
|
||||
* {@code quietPeriod} will start over.
|
||||
* @since 5.2.4
|
||||
* @see #setShutdownTimeout(Duration)
|
||||
*/
|
||||
public void setShutdownQuietPeriod(Duration shutdownQuietPeriod) {
|
||||
Assert.notNull(shutdownQuietPeriod, "shutdownQuietPeriod should not be null");
|
||||
this.shutdownQuietPeriod = shutdownQuietPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the maximum amount of time to wait until the disposal of the underlying
|
||||
* resources regardless if a task was submitted during the {@code shutdownQuietPeriod}.
|
||||
* @since 5.2.4
|
||||
* @see #setShutdownTimeout(Duration)
|
||||
*/
|
||||
public void setShutdownTimeout(Duration shutdownTimeout) {
|
||||
Assert.notNull(shutdownTimeout, "shutdownQuietPeriod should not be null");
|
||||
this.shutdownTimeout = shutdownTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Consumer for configuring the global Reactor Netty resources on
|
||||
* startup. When this option is used, {@link #setUseGlobalResources} is also
|
||||
|
|
@ -125,7 +102,7 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
}
|
||||
|
||||
/**
|
||||
* Use this option when you don't want to participate in global resources and
|
||||
* Use this when you don't want to participate in global resources and
|
||||
* you want to customize the creation of the managed {@code ConnectionProvider}.
|
||||
* <p>By default, {@code ConnectionProvider.elastic("http")} is used.
|
||||
* <p>Note that this option is ignored if {@code userGlobalResources=false} or
|
||||
|
|
@ -137,19 +114,7 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
}
|
||||
|
||||
/**
|
||||
* Use this option when you don't want to participate in global resources and
|
||||
* you want to customize the creation of the managed {@code LoopResources}.
|
||||
* <p>By default, {@code LoopResources.create("reactor-http")} is used.
|
||||
* <p>Note that this option is ignored if {@code userGlobalResources=false} or
|
||||
* {@link #setLoopResources(LoopResources)} is set.
|
||||
* @param supplier the supplier to use
|
||||
*/
|
||||
public void setLoopResourcesSupplier(Supplier<LoopResources> supplier) {
|
||||
this.loopResourcesSupplier = supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this option when you want to provide an externally managed
|
||||
* Use this when you want to provide an externally managed
|
||||
* {@link ConnectionProvider} instance.
|
||||
* @param connectionProvider the connection provider to use as is
|
||||
*/
|
||||
|
|
@ -165,6 +130,18 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
return this.connectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this when you don't want to participate in global resources and
|
||||
* you want to customize the creation of the managed {@code LoopResources}.
|
||||
* <p>By default, {@code LoopResources.create("reactor-http")} is used.
|
||||
* <p>Note that this option is ignored if {@code userGlobalResources=false} or
|
||||
* {@link #setLoopResources(LoopResources)} is set.
|
||||
* @param supplier the supplier to use
|
||||
*/
|
||||
public void setLoopResourcesSupplier(Supplier<LoopResources> supplier) {
|
||||
this.loopResourcesSupplier = supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this option when you want to provide an externally managed
|
||||
* {@link LoopResources} instance.
|
||||
|
|
@ -182,6 +159,40 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
return this.loopResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the amount of time we'll wait before shutting down resources.
|
||||
* If a task is submitted during the {@code quietPeriod}, it is guaranteed
|
||||
* to be accepted and the {@code quietPeriod} will start over.
|
||||
* <p>By default, this is set to
|
||||
* {@link LoopResources#DEFAULT_SHUTDOWN_QUIET_PERIOD} which is 2 seconds but
|
||||
* can also be overridden with the system property
|
||||
* {@link reactor.netty.ReactorNetty#SHUTDOWN_QUIET_PERIOD
|
||||
* ReactorNetty.SHUTDOWN_QUIET_PERIOD}.
|
||||
* @since 5.2.4
|
||||
* @see #setShutdownTimeout(Duration)
|
||||
*/
|
||||
public void setShutdownQuietPeriod(Duration shutdownQuietPeriod) {
|
||||
Assert.notNull(shutdownQuietPeriod, "shutdownQuietPeriod should not be null");
|
||||
this.shutdownQuietPeriod = shutdownQuietPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the maximum amount of time to wait until the disposal of the
|
||||
* underlying resources regardless if a task was submitted during the
|
||||
* {@code shutdownQuietPeriod}.
|
||||
* <p>By default, this is set to
|
||||
* {@link LoopResources#DEFAULT_SHUTDOWN_TIMEOUT} which is 15 seconds but
|
||||
* can also be overridden with the system property
|
||||
* {@link reactor.netty.ReactorNetty#SHUTDOWN_TIMEOUT
|
||||
* ReactorNetty.SHUTDOWN_TIMEOUT}.
|
||||
* @since 5.2.4
|
||||
* @see #setShutdownQuietPeriod(Duration)
|
||||
*/
|
||||
public void setShutdownTimeout(Duration shutdownTimeout) {
|
||||
Assert.notNull(shutdownTimeout, "shutdownQuietPeriod should not be null");
|
||||
this.shutdownTimeout = shutdownTimeout;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
|
|
@ -210,7 +221,8 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean
|
|||
@Override
|
||||
public void destroy() {
|
||||
if (this.useGlobalResources) {
|
||||
HttpResources.disposeLoopsAndConnectionsLater(this.shutdownQuietPeriod, this.shutdownTimeout).block();
|
||||
HttpResources.disposeLoopsAndConnectionsLater(
|
||||
this.shutdownQuietPeriod, this.shutdownTimeout).block();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue