Administrator
2026-08-13 c1d984b2a937f8d3bfe94a9ec724f438994fe6bd
feat(gate): 添加策略端组件开关配置

- 在 application.yml 中新增 app.gate.enabled 配置项,默认值为 false
- 为 CommandQueueInitializer 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateCommandConsumer 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateConfigController 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateConfigPersistenceService 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateLogBuffer 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateWebSocketClientManager 添加 ConditionalOnProperty 注解控制条件加载
- 为 HeartbeatScheduler 添加 ConditionalOnProperty 注解控制条件加载
- 为 StatsEventProducer 添加 ConditionalOnProperty 注解控制条件加载
9 files modified
19 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/CommandQueueInitializer.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateConfigController.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateConfigPersistenceService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateLogBuffer.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/HeartbeatScheduler.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/StatsEventProducer.java 2 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/CommandQueueInitializer.java
@@ -2,6 +2,7 @@
import com.xcong.excoin.configurations.RabbitMqConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
@@ -16,6 +17,7 @@
 * JAR 启动时动态创建专属命令队列 QUEUE_GATE_CMD_{apiKeyMd5}
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Component
@DependsOn("gateWebSocketClientManager")
public class CommandQueueInitializer {
src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java
@@ -5,6 +5,7 @@
import com.xcong.excoin.modules.station.model.GateCommand;
import com.xcong.excoin.modules.station.model.GateStatsEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -15,6 +16,7 @@
 * JAR 侧 — 消费 Station 下发的启停指令
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Component
public class GateCommandConsumer {
src/main/java/com/xcong/excoin/modules/gateApi/GateConfigController.java
@@ -4,6 +4,7 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -13,6 +14,7 @@
 * Gate 配置控制面板 REST 接口。
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@RestController
@RequestMapping("/api/gate")
@Api(tags = "Gate配置管理")
src/main/java/com/xcong/excoin/modules/gateApi/GateConfigPersistenceService.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@@ -18,6 +19,7 @@
 * 文件路径: config/gate-config-{md5(apiKey)}.json
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Service
public class GateConfigPersistenceService {
src/main/java/com/xcong/excoin/modules/gateApi/GateLogBuffer.java
@@ -1,6 +1,7 @@
package com.xcong.excoin.modules.gateApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
@@ -17,6 +18,7 @@
 * 最多保留 500 条日志,新客户端连接时先推送历史再持续推新日志。
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Service
public class GateLogBuffer {
src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java
@@ -5,6 +5,7 @@
import com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionClosesChannelHandler;
import com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionsChannelHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -42,6 +43,7 @@
 * @author Administrator
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Component
public class GateWebSocketClientManager {
src/main/java/com/xcong/excoin/modules/gateApi/HeartbeatScheduler.java
@@ -3,6 +3,7 @@
import com.xcong.excoin.modules.station.model.GateStatsEvent;
import com.xcong.excoin.modules.station.model.HeartbeatMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -15,6 +16,7 @@
 * JAR 侧 — 心跳定时发送(每 30s)
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Component
@EnableScheduling
public class HeartbeatScheduler {
src/main/java/com/xcong/excoin/modules/gateApi/StatsEventProducer.java
@@ -4,6 +4,7 @@
import com.xcong.excoin.configurations.RabbitMqConfig;
import com.xcong.excoin.modules.station.model.GateStatsEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,6 +16,7 @@
 * JAR 侧 — 统一消息发送器(心跳 / ACK / 策略事件 / Stats)
 */
@Slf4j
@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
@Component
public class StatsEventProducer {
src/main/resources/application.yml
@@ -92,6 +92,9 @@
app:
  debug: false
  redis_expire: 3000
  # gate 策略端组件开关:false=屏蔽策略组件加载(Station 用);策略 JAR 分支保持默认(不设或 true)
  gate:
    enabled: false
  # k线更新任务控制
  kline-update-job: false
  #最新价任务控制