1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use super::log_compaction_type::LogCompactionType;
/// `RuntimeServerConfig` 消费的启动选项子集。
///
/// 对标 libs/server/Servers/GarnetServerOptions.cs:GarnetServerOptions 中被
/// RuntimeServerConfig 构造(Init 播种 + 只读回落格式化)读取的字段。
///
/// 字段默认值与 C# 字段初始化器逐项一致。
#[derive(Debug, Clone)]
pub struct RuntimeServerOptions {
// —— Init 播种字段 ——
/// GarnetServerOptions.cs:ClusterTimeout(默认 60,秒)。
pub cluster_timeout: i32,
/// GarnetServerOptions.cs:ReplicaSyncDelayMs(默认 5,毫秒)。
pub replica_sync_delay_ms: i32,
/// GarnetServerOptions.cs:AofReplayMaxLagBytes(默认 -1)。
pub aof_replay_max_lag_bytes: i32,
/// GarnetServerOptions.cs:AofTailWitnessFreqMs(默认 100,毫秒)。
pub aof_tail_witness_freq_ms: i32,
/// GarnetServerOptions.cs:AofSyncMaxLagBytes(默认 -1)。
pub aof_sync_max_lag_bytes: i64,
/// GarnetServerOptions.cs:ReplicaDisklessSyncDelay(默认 5,秒)。
pub replica_diskless_sync_delay: i32,
/// GarnetServerOptions.cs:ReplicaAttachTimeout(C# 为 TimeSpan,此处以秒表达;
/// CLI/CONFIG 面的秒数语义:<= 0 视为无限超时)。
pub replica_attach_timeout_secs: i64,
/// GarnetServerOptions.cs:ClusterReplicationReestablishmentTimeout(默认 0,秒)。
pub cluster_replication_reestablishment_timeout: i32,
/// GarnetServerOptions.cs:CompactionMaxSegments(默认 32)。
pub compaction_max_segments: i32,
/// GarnetServerOptions.cs:CompactionForceDelete(默认 false)。
pub compaction_force_delete: bool,
/// GarnetServerOptions.cs:CompactionType(默认 None)。
pub compaction_type: LogCompactionType,
/// GarnetServerOptions.cs:SlowLogThreshold(默认 0,微秒)。
pub slow_log_threshold: i32,
/// GarnetServerOptions.cs:ObjectScanCountLimit(默认 1000)。
pub object_scan_count_limit: i32,
/// GarnetServerOptions.cs:EnableScatterGatherGet(默认 true)。
pub enable_scatter_gather_get: bool,
/// GarnetServerOptions.cs:AofSizeLimitEnforceFrequencySecs(默认 5,秒)。
pub aof_size_limit_enforce_frequency_secs: i32,
/// GarnetServerOptions.cs:CommitFrequencyMs(默认 0:逐操作自动提交)。
pub commit_frequency_ms: i32,
/// GarnetServerOptions.cs:ExpiredObjectCollectionFrequencySecs(默认 0:禁用)。
pub expired_object_collection_frequency_secs: i32,
/// GarnetServerOptions.cs:ExpiredKeyDeletionScanFrequencySecs(默认 -1:禁用)。
pub expired_key_deletion_scan_frequency_secs: i32,
// —— 只读回落格式化字段(CONFIG GET 经选项直读,无运行时槽位)——
/// GarnetServerOptions.cs:EnableAOF(默认 false)。
pub enable_aof: bool,
/// GarnetServerOptions.cs:MaxDatabases(默认 16)。
pub max_databases: i32,
/// GarnetServerOptions.cs:CheckpointBaseDirectory(派生属性)。
pub checkpoint_base_directory: String,
/// GarnetServerOptions.cs:LogDir(可空)。
pub log_dir: Option<String>,
/// GarnetServerOptions.cs:UnixSocketPath(可空)。
pub unix_socket_path: Option<String>,
/// GarnetServerOptions.cs:EnableCluster(默认 false)。
pub enable_cluster: bool,
/// GarnetServerOptions.cs:AofMemorySize(默认 "128m")。
pub aof_memory_size: Option<String>,
/// GarnetServerOptions.cs:AofPageSize(默认 "32m")。
pub aof_page_size: Option<String>,
/// GarnetServerOptions.cs:AofSegmentSize(默认 "1g")。
pub aof_segment_size: Option<String>,
/// GarnetServerOptions.cs:AofPhysicalSublogCount(默认 1)。
pub aof_physical_sublog_count: i32,
/// GarnetServerOptions.cs:AofReplayTaskCount(默认 1)。
pub aof_replay_task_count: i32,
/// GarnetServerOptions.cs:WaitForCommit(默认 false)。
pub wait_for_commit: bool,
/// GarnetServerOptions.cs:AofSizeLimit(默认 "")。
pub aof_size_limit: Option<String>,
/// GarnetServerOptions.cs:FastAofTruncate(默认 false)。
pub fast_aof_truncate: bool,
/// GarnetServerOptions.cs:UseAofNullDevice(默认 false)。
pub use_aof_null_device: bool,
}
impl Default for RuntimeServerOptions {
/// 逐字段对齐 GarnetServerOptions.cs 的字段初始化器。
fn default() -> Self {
Self {
cluster_timeout: 60,
replica_sync_delay_ms: 5,
aof_replay_max_lag_bytes: -1,
aof_tail_witness_freq_ms: 100,
aof_sync_max_lag_bytes: -1,
replica_diskless_sync_delay: 5,
replica_attach_timeout_secs: 60,
cluster_replication_reestablishment_timeout: 0,
compaction_max_segments: 32,
compaction_force_delete: false,
compaction_type: LogCompactionType::None,
slow_log_threshold: 0,
object_scan_count_limit: 1000,
enable_scatter_gather_get: true,
aof_size_limit_enforce_frequency_secs: 5,
commit_frequency_ms: 0,
expired_object_collection_frequency_secs: 0,
expired_key_deletion_scan_frequency_secs: -1,
enable_aof: false,
max_databases: 16,
checkpoint_base_directory: String::new(),
log_dir: None,
unix_socket_path: None,
enable_cluster: false,
aof_memory_size: Some("128m".into()),
aof_page_size: Some("32m".into()),
aof_segment_size: Some("1g".into()),
aof_physical_sublog_count: 1,
aof_replay_task_count: 1,
wait_for_commit: false,
aof_size_limit: Some(String::new()),
fast_aof_truncate: false,
use_aof_null_device: false,
}
}
}