RobotStatusSync.cs 2.88 KB
namespace Rcs.Domain.Settings
{
    /// <summary>
    /// Robot状态管理配置
    /// </summary>
    public record RobotStatusSync
    {
        /// <summary>
        /// Redis TTL(秒)- Robot状态在Redis中的过期时间
        /// </summary>
        public int RedisTtlSeconds { get; init; } = 60;
        
        /// <summary>
        /// 启用Redis压缩
        /// </summary>
        public bool EnableRedisCompression { get; init; } = false;
        
        /// <summary>
        /// 数据库同步间隔(毫秒)
        /// </summary>
        public int DbSyncIntervalMs { get; init; } = 3000;
        
        /// <summary>
        /// 数据库同步批次大小
        /// </summary>
        public int DbSyncBatchSize { get; init; } = 100;
        
        /// <summary>
        /// 启用智能同步(只同步有显著变化的数据)
        /// </summary>
        public bool EnableSmartSync { get; init; } = true;
        
        /// <summary>
        /// 位置变化阈值(米)- 超过此值才同步
        /// </summary>
        public double PositionChangeThreshold { get; init; } = 0.1;
        
        /// <summary>
        /// 电池电量变化阈值(%)- 超过此值才同步
        /// </summary>
        public double BatteryChangeThreshold { get; init; } = 1.0;
        
        /// <summary>
        /// 启用Redis管道批处理
        /// </summary>
        public bool EnableRedisPipeline { get; init; } = true;
        
        /// <summary>
        /// 管道批次大小
        /// </summary>
        public int PipelineBatchSize { get; init; } = 50;
        
        /// <summary>
        /// 管道刷新间隔(毫秒)
        /// </summary>
        public int PipelineFlushIntervalMs { get; init; } = 50;
        
        /// <summary>
        /// 启用启动预热
        /// </summary>
        public bool EnableStartupPrewarm { get; init; } = true;
        
        /// <summary>
        /// 预热最大Robot数量
        /// </summary>
        public int PrewarmMaxRobots { get; init; } = 1000;
        
        /// <summary>
        /// 关闭配置
        /// </summary>
        public GracefulShutdownSettings GracefulShutdown { get; init; } = new();
    }
    
    /// <summary>
    /// 关闭配置
    /// </summary>
    public record GracefulShutdownSettings
    {
        /// <summary>
        /// 启用关闭
        /// </summary>
        public bool Enabled { get; init; } = true;
        
        /// <summary>
        /// 超时时间(秒)
        /// </summary>
        public int TimeoutSeconds { get; init; } = 30;
        
        /// <summary>
        /// 保存同步报告到文件
        /// </summary>
        public bool SaveSyncReportToFile { get; init; } = true;
        
        /// <summary>
        /// 记录详细进度
        /// </summary>
        public bool LogDetailedProgress { get; init; } = true;
    }
}