feat(gate): 添加策略端组件开关配置
- 在 application.yml 中新增 app.gate.enabled 配置项,默认值为 false
- 为 CommandQueueInitializer 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateCommandConsumer 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateConfigController 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateConfigPersistenceService 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateLogBuffer 添加 ConditionalOnProperty 注解控制条件加载
- 为 GateWebSocketClientManager 添加 ConditionalOnProperty 注解控制条件加载
- 为 HeartbeatScheduler 添加 ConditionalOnProperty 注解控制条件加载
- 为 StatsEventProducer 添加 ConditionalOnProperty 注解控制条件加载
| | |
| | | |
| | | 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; |
| | |
| | | * JAR 启动时动态创建专属命令队列 QUEUE_GATE_CMD_{apiKeyMd5} |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Component |
| | | @DependsOn("gateWebSocketClientManager") |
| | | public class CommandQueueInitializer { |
| | |
| | | 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; |
| | |
| | | * JAR 侧 — 消费 Station 下发的启停指令 |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Component |
| | | public class GateCommandConsumer { |
| | | |
| | |
| | | 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.*; |
| | |
| | | * Gate 配置控制面板 REST 接口。 |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @RestController |
| | | @RequestMapping("/api/gate") |
| | | @Api(tags = "Gate配置管理") |
| | |
| | | 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; |
| | |
| | | * 文件路径: config/gate-config-{md5(apiKey)}.json |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Service |
| | | public class GateConfigPersistenceService { |
| | | |
| | |
| | | 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; |
| | | |
| | |
| | | * 最多保留 500 条日志,新客户端连接时先推送历史再持续推新日志。 |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Service |
| | | public class GateLogBuffer { |
| | | |
| | |
| | | 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; |
| | | |
| | |
| | | * @author Administrator |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Component |
| | | public class GateWebSocketClientManager { |
| | | |
| | |
| | | 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; |
| | |
| | | * JAR 侧 — 心跳定时发送(每 30s) |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Component |
| | | @EnableScheduling |
| | | public class HeartbeatScheduler { |
| | |
| | | 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; |
| | |
| | | * JAR 侧 — 统一消息发送器(心跳 / ACK / 策略事件 / Stats) |
| | | */ |
| | | @Slf4j |
| | | @ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true) |
| | | @Component |
| | | public class StatsEventProducer { |
| | | |
| | |
| | | app: |
| | | debug: false |
| | | redis_expire: 3000 |
| | | # gate 策略端组件开关:false=屏蔽策略组件加载(Station 用);策略 JAR 分支保持默认(不设或 true) |
| | | gate: |
| | | enabled: false |
| | | # k线更新任务控制 |
| | | kline-update-job: false |
| | | #最新价任务控制 |