Rename WebFluxConfig to WebServerConfig
This commit is contained in:
@@ -1,157 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package we.config;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
|
||||||
import org.springframework.http.codec.multipart.MultipartHttpMessageReader;
|
|
||||||
import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader;
|
|
||||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
|
||||||
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hongqiaowei
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@ConfigurationProperties(prefix = "server")
|
|
||||||
@EnableConfigurationProperties(ServerProperties.class)
|
|
||||||
public class WebFluxConfig {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(WebFluxConfig.class);
|
|
||||||
|
|
||||||
// @NacosValue(value = "${server.connection-pool.max-connections:500}", autoRefreshed = true)
|
|
||||||
// @Value( "${server.connection-pool.max-connections:500}" )
|
|
||||||
// private int maxConnections;
|
|
||||||
//
|
|
||||||
// @NacosValue(value = "${server.connection-pool.max-idle-time:30000}", autoRefreshed = true)
|
|
||||||
// @Value( "${server.connection-pool.max-idle-time:30000}" )
|
|
||||||
// private long maxIdleTime;
|
|
||||||
|
|
||||||
// private ConnectionProvider connectionProvider() {
|
|
||||||
// ConnectionProvider connectionProvider = ConnectionProvider.builder("fizz-cp")
|
|
||||||
// .maxConnections(maxConnections)
|
|
||||||
// .maxIdleTime(Duration.ofMillis(maxIdleTime))
|
|
||||||
// .pendingAcquireMaxCount(-1)
|
|
||||||
// .build();
|
|
||||||
// log.info("server connection provider: maxConnections={}, maxIdleTime={}", maxConnections, maxIdleTime);
|
|
||||||
// return connectionProvider;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @ConditionalOnBean(ReactorResourceFactory.class)
|
|
||||||
// @Bean(name = "$dummyObject")
|
|
||||||
// public Object dummyObject() {
|
|
||||||
// ConnectionProvider provider = connectionProvider();
|
|
||||||
// HttpResources.set(provider);
|
|
||||||
// log.info("replace default connection provider with: " + provider);
|
|
||||||
// return new Object();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private LoopResources loopResources() {
|
|
||||||
// LoopResources loopResources = LoopResources.create("fizz-lrs");
|
|
||||||
// log.info("server loop resources: " + loopResources);
|
|
||||||
// return loopResources;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Bean
|
|
||||||
// public ReactorResourceFactory reactorServerResourceFactory() {
|
|
||||||
// ReactorResourceFactory rrf = new ReactorResourceFactory();
|
|
||||||
// rrf.setUseGlobalResources(false);
|
|
||||||
// rrf.setLoopResources(loopResources());
|
|
||||||
// rrf.setConnectionProvider(connectionProvider());
|
|
||||||
// log.info("server reactor resource factory: " + rrf);
|
|
||||||
// return rrf;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Bean
|
|
||||||
// public NettyReactiveWebServerFactory nettyReactiveWebServerFactory(ServerProperties serverProperties/*, ReactorResourceFactory reactorResourceFactory*/) {
|
|
||||||
// NettyReactiveWebServerFactory httpServerFactory = new NettyReactiveWebServerFactory();
|
|
||||||
// httpServerFactory.setResourceFactory(null);
|
|
||||||
// // httpServerFactory.setResourceFactory(reactorResourceFactory);
|
|
||||||
// // LoopResources lr = LoopResources.create("fizz-el", 1, Runtime.getRuntime().availableProcessors(), true);
|
|
||||||
// httpServerFactory.addServerCustomizers(
|
|
||||||
// httpServer -> (
|
|
||||||
// httpServer.tcpConfiguration(
|
|
||||||
// tcpServer -> {
|
|
||||||
// return (
|
|
||||||
// tcpServer
|
|
||||||
// // .runOn(lr, true)
|
|
||||||
// // .runOn(lr)
|
|
||||||
// // .selectorOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
|
|
||||||
// // .port(7777)
|
|
||||||
// .bootstrap(
|
|
||||||
// serverBootstrap -> (
|
|
||||||
// serverBootstrap
|
|
||||||
// // .group(parentGroup, childGroup)
|
|
||||||
// // .channel(NioServerSocketChannel.class)
|
|
||||||
// // .handler(new LoggingHandler(LogLevel.DEBUG))
|
|
||||||
// // .childHandler(new ChannelInitializer<SocketChannel>() {
|
|
||||||
// // @Override
|
|
||||||
// // public void initChannel(final SocketChannel socketChannel) {
|
|
||||||
// // socketChannel.pipeline().addLast(new BufferingInboundHandler());
|
|
||||||
// // }
|
|
||||||
// // })
|
|
||||||
// // .channel(NioServerSocketChannel.class)
|
|
||||||
// // .option(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT)
|
|
||||||
// // .option(ChannelOption.SO_BACKLOG, 8192)
|
|
||||||
// // .childOption(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT)
|
|
||||||
// .childOption(ChannelOption.SO_KEEPALIVE, true)
|
|
||||||
// .childOption(ChannelOption.TCP_NODELAY, true)
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// return httpServerFactory;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebFlux
|
|
||||||
public static class FizzWebFluxConfigurer implements WebFluxConfigurer {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private WebFluxConfigProperties webFluxConfigProperties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
|
|
||||||
configurer.defaultCodecs().maxInMemorySize(-1);
|
|
||||||
SynchronossPartHttpMessageReader partReader = new SynchronossPartHttpMessageReader();
|
|
||||||
partReader.setMaxParts(webFluxConfigProperties.getMaxParts());
|
|
||||||
partReader.setMaxDiskUsagePerPart(webFluxConfigProperties.getMaxDiskUsagePerPart());
|
|
||||||
MultipartHttpMessageReader multipartReader = new MultipartHttpMessageReader(partReader);
|
|
||||||
configurer.defaultCodecs().multipartReader(multipartReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry.addResourceHandler("/*.*")
|
|
||||||
.addResourceLocations("classpath:/static/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
71
fizz-core/src/main/java/we/config/WebServerConfig.java
Normal file
71
fizz-core/src/main/java/we/config/WebServerConfig.java
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 the original author or authors.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package we.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||||
|
import org.springframework.http.codec.multipart.MultipartHttpMessageReader;
|
||||||
|
import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader;
|
||||||
|
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||||
|
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongqiaowei
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "server")
|
||||||
|
@EnableConfigurationProperties(ServerProperties.class)
|
||||||
|
public class WebServerConfig {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(WebServerConfig.class);
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebFlux
|
||||||
|
public static class FizzWebFluxConfigurer implements WebFluxConfigurer {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WebServerConfigProperties webServerConfigProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
|
||||||
|
ServerCodecConfigurer.ServerDefaultCodecs serverDefaultCodecs = configurer.defaultCodecs();
|
||||||
|
serverDefaultCodecs.maxInMemorySize(-1);
|
||||||
|
|
||||||
|
SynchronossPartHttpMessageReader partReader = new SynchronossPartHttpMessageReader();
|
||||||
|
partReader.setMaxParts(webServerConfigProperties.getMaxParts());
|
||||||
|
partReader.setMaxDiskUsagePerPart(webServerConfigProperties.getMaxDiskUsagePerPart());
|
||||||
|
MultipartHttpMessageReader multipartReader = new MultipartHttpMessageReader(partReader);
|
||||||
|
serverDefaultCodecs.multipartReader(multipartReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("/*.*")
|
||||||
|
.addResourceLocations("classpath:/static/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,44 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 the original author or authors.
|
* Copyright (C) 2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* any later version.
|
* any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package we.config;
|
|
||||||
|
package we.config;
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import lombok.Data;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
/**
|
|
||||||
* {@link WebFluxConfig} properties
|
/**
|
||||||
*
|
* {@link WebServerConfig} properties
|
||||||
* @author zhongjie
|
*
|
||||||
*/
|
* @author zhongjie
|
||||||
@RefreshScope
|
*/
|
||||||
@Component
|
|
||||||
@Data
|
@RefreshScope
|
||||||
public class WebFluxConfigProperties {
|
@Component
|
||||||
/**
|
@Data
|
||||||
* Configure the maximum amount of disk space allowed for file parts. Default 100M (104857600)
|
public class WebServerConfigProperties {
|
||||||
*/
|
|
||||||
@Value( "${server.fileUpload.maxDiskUsagePerPart:104857600}" )
|
/**
|
||||||
private long maxDiskUsagePerPart;
|
* Configure the maximum amount of disk space allowed for file parts. Default 100M (104857600)
|
||||||
|
*/
|
||||||
/**
|
@Value( "${server.fileUpload.maxDiskUsagePerPart:104857600}" )
|
||||||
* Maximum parts of multipart form-data, including form field parts; Default -1 no limit
|
private long maxDiskUsagePerPart;
|
||||||
*/
|
|
||||||
@Value( "${server.fileUpload.maxParts:-1}" )
|
/**
|
||||||
private int maxParts;
|
* Maximum parts of multipart form-data, including form field parts; Default -1 no limit
|
||||||
}
|
*/
|
||||||
|
@Value( "${server.fileUpload.maxParts:-1}" )
|
||||||
|
private int maxParts;
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ we.config.FlowStatSchedConfig,\
|
|||||||
we.config.ProxyWebClientConfig,\
|
we.config.ProxyWebClientConfig,\
|
||||||
we.config.RefreshLocalCacheConfig,\
|
we.config.RefreshLocalCacheConfig,\
|
||||||
we.config.SystemConfig,\
|
we.config.SystemConfig,\
|
||||||
we.config.WebFluxConfig,\
|
we.config.WebServerConfig,\
|
||||||
we.controller.HealthCheckController,\
|
we.controller.HealthCheckController,\
|
||||||
we.controller.CacheCheckController,\
|
we.controller.CacheCheckController,\
|
||||||
we.controller.CallbackController,\
|
we.controller.CallbackController,\
|
||||||
|
|||||||
Reference in New Issue
Block a user