fix: align split app runtime dependencies
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -12,6 +12,8 @@ lingniu:
|
||||
ingest:
|
||||
gb32960:
|
||||
enabled: true
|
||||
server:
|
||||
enabled: true
|
||||
port: ${GB32960_PORT:32960}
|
||||
boss-threads: ${GB32960_BOSS_THREADS:1}
|
||||
worker-threads: ${GB32960_WORKER_THREADS:0}
|
||||
|
||||
@@ -11,6 +11,8 @@ server:
|
||||
lingniu:
|
||||
ingest:
|
||||
gb32960:
|
||||
enabled: true
|
||||
server:
|
||||
enabled: false
|
||||
sink:
|
||||
mq:
|
||||
|
||||
@@ -55,5 +55,10 @@
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -59,8 +59,8 @@ import java.util.List;
|
||||
* <p>每个 Parser Bean 都会被 {@link InfoBlockParserRegistry} 按
|
||||
* {@code (ProtocolVersion, typeCode)} 注册。2016/2025 可同时加载。
|
||||
*
|
||||
* <p>只有 {@code lingniu.ingest.gb32960.enabled=true} 时才会启动 32960 TCP 服务。
|
||||
* 解析、鉴权、ACK、RAW 入库都从 {@link Gb32960NettyServer} 建立的 Netty pipeline 进入。
|
||||
* <p>只有 {@code lingniu.ingest.gb32960.enabled=true} 时才会装配 32960 协议解析组件。
|
||||
* TCP 监听由 {@code lingniu.ingest.gb32960.server.enabled} 单独控制。
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@EnableConfigurationProperties(Gb32960Properties.class)
|
||||
@@ -222,6 +222,8 @@ public class Gb32960AutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(prefix = "lingniu.ingest.gb32960.server", name = "enabled",
|
||||
havingValue = "true", matchIfMissing = true)
|
||||
public Gb32960NettyServer gb32960NettyServer(Gb32960Properties props,
|
||||
Gb32960MessageDecoder decoder,
|
||||
Dispatcher dispatcher,
|
||||
|
||||
@@ -10,8 +10,10 @@ import java.util.Set;
|
||||
@ConfigurationProperties(prefix = "lingniu.ingest.gb32960")
|
||||
public class Gb32960Properties {
|
||||
|
||||
/** 是否启动 32960 TCP 监听。生产 32960 线路打开后,此开关决定端口是否真正 bind。 */
|
||||
/** 是否装配 32960 协议解析组件。TCP 监听由 {@link #server} 单独控制。 */
|
||||
private boolean enabled = false;
|
||||
/** 32960 TCP 监听开关。默认跟随协议启用后启动,查询类应用可单独关闭。 */
|
||||
private Server server = new Server();
|
||||
/** 32960 TCP 监听端口;当前生产验证线使用 32960。 */
|
||||
private int port = 9000;
|
||||
/** Netty worker 线程数;0 表示按 Netty/CPU 默认策略分配。 */
|
||||
@@ -63,6 +65,8 @@ public class Gb32960Properties {
|
||||
|
||||
public boolean isEnabled() { return enabled; }
|
||||
public void setEnabled(boolean enabled) { this.enabled = enabled; }
|
||||
public Server getServer() { return server; }
|
||||
public void setServer(Server server) { this.server = server; }
|
||||
public int getPort() { return port; }
|
||||
public void setPort(int port) { this.port = port; }
|
||||
public int getWorkerThreads() { return workerThreads; }
|
||||
@@ -82,6 +86,13 @@ public class Gb32960Properties {
|
||||
this.vendorExtensions = vendorExtensions;
|
||||
}
|
||||
|
||||
public static class Server {
|
||||
private boolean enabled = true;
|
||||
|
||||
public boolean isEnabled() { return enabled; }
|
||||
public void setEnabled(boolean enabled) { this.enabled = enabled; }
|
||||
}
|
||||
|
||||
/**
|
||||
* VIN 白名单认证。
|
||||
*
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lingniu.ingest.protocol.gb32960.config;
|
||||
|
||||
import com.lingniu.ingest.core.dispatcher.Dispatcher;
|
||||
import com.lingniu.ingest.protocol.gb32960.codec.Gb32960MessageDecoder;
|
||||
import com.lingniu.ingest.protocol.gb32960.inbound.Gb32960NettyServer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class Gb32960AutoConfigurationTest {
|
||||
|
||||
private final ApplicationContextRunner runner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(Gb32960AutoConfiguration.class))
|
||||
.withBean(Dispatcher.class, () -> new Dispatcher(null, null, null, null, null))
|
||||
.withPropertyValues(
|
||||
"lingniu.ingest.gb32960.enabled=true",
|
||||
"lingniu.ingest.gb32960.port=0");
|
||||
|
||||
@Test
|
||||
void createsDecoderWithoutTcpServerWhenServerDisabled() {
|
||||
runner.withPropertyValues("lingniu.ingest.gb32960.server.enabled=false")
|
||||
.run(context -> {
|
||||
assertThat(context).hasSingleBean(Gb32960MessageDecoder.class);
|
||||
assertThat(context).doesNotHaveBean(Gb32960NettyServer.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsTcpServerByDefaultWhenProtocolEnabled() {
|
||||
runner.run(context -> {
|
||||
assertThat(context).hasSingleBean(Gb32960MessageDecoder.class);
|
||||
assertThat(context).hasSingleBean(Gb32960NettyServer.class);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user