/
config.rs
121 lines (93 loc) 路 3.08 KB
/
config.rs
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
// Sonic
//
// Fast, lightweight and schema-less search backend
// Copyright: 2019, Valerian Saliou <valerian@valeriansaliou.name>
// License: Mozilla Public License v2.0 (MPL v2.0)
use std::net::SocketAddr;
use std::path::PathBuf;
use super::defaults;
#[derive(Deserialize)]
pub struct Config {
pub server: ConfigServer,
pub channel: ConfigChannel,
pub store: ConfigStore,
}
#[derive(Deserialize)]
pub struct ConfigServer {
#[serde(default = "defaults::server_log_level")]
pub log_level: String,
}
#[derive(Deserialize)]
pub struct ConfigChannel {
#[serde(default = "defaults::channel_inet")]
pub inet: SocketAddr,
#[serde(default = "defaults::channel_tcp_timeout")]
pub tcp_timeout: u64,
pub auth_password: Option<String>,
pub search: ConfigChannelSearch,
}
#[derive(Deserialize)]
pub struct ConfigChannelSearch {
#[serde(default = "defaults::channel_search_query_limit_default")]
pub query_limit_default: u16,
#[serde(default = "defaults::channel_search_query_limit_maximum")]
pub query_limit_maximum: u16,
#[serde(default = "defaults::channel_search_query_alternates_try")]
pub query_alternates_try: usize,
#[serde(default = "defaults::channel_search_suggest_limit_default")]
pub suggest_limit_default: u16,
#[serde(default = "defaults::channel_search_suggest_limit_maximum")]
pub suggest_limit_maximum: u16,
}
#[derive(Deserialize)]
pub struct ConfigStore {
pub kv: ConfigStoreKV,
pub fst: ConfigStoreFST,
}
#[derive(Deserialize)]
pub struct ConfigStoreKV {
#[serde(default = "defaults::store_kv_path")]
pub path: PathBuf,
#[serde(default = "defaults::store_kv_retain_word_objects")]
pub retain_word_objects: usize,
pub pool: ConfigStoreKVPool,
pub database: ConfigStoreKVDatabase,
}
#[derive(Deserialize)]
pub struct ConfigStoreKVPool {
#[serde(default = "defaults::store_kv_pool_inactive_after")]
pub inactive_after: u64,
}
#[derive(Deserialize)]
pub struct ConfigStoreKVDatabase {
#[serde(default = "defaults::store_kv_database_compress")]
pub compress: bool,
#[serde(default = "defaults::store_kv_database_parallelism")]
pub parallelism: u16,
pub max_files: Option<u32>,
#[serde(default = "defaults::store_kv_database_max_compactions")]
pub max_compactions: u16,
#[serde(default = "defaults::store_kv_database_max_flushes")]
pub max_flushes: u16,
#[serde(default = "defaults::store_kv_database_write_buffer")]
pub write_buffer: usize,
#[serde(default = "defaults::store_kv_database_write_ahead_log")]
pub write_ahead_log: bool,
}
#[derive(Deserialize)]
pub struct ConfigStoreFST {
#[serde(default = "defaults::store_fst_path")]
pub path: PathBuf,
pub pool: ConfigStoreFSTPool,
pub graph: ConfigStoreFSTGraph,
}
#[derive(Deserialize)]
pub struct ConfigStoreFSTPool {
#[serde(default = "defaults::store_fst_pool_inactive_after")]
pub inactive_after: u64,
}
#[derive(Deserialize)]
pub struct ConfigStoreFSTGraph {
#[serde(default = "defaults::store_fst_graph_consolidate_after")]
pub consolidate_after: u64,
}