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
use std::time::Duration;
use exocore_protos::core::NodeStoreConfig;
/// Configuration for `Store`.
#[derive(Clone, Copy)]
pub struct StoreConfig {
/// Size of the channel of queries to be executed.
pub query_channel_size: usize,
/// Maximum number fo queries to execute in parallel.
pub query_parallelism: usize,
/// Size of the result channel of each watched query.
pub handle_watch_query_channel_size: usize,
/// Maximum number of events from chain engine to batch together if more are
/// available.
pub chain_events_batch_size: usize,
/// Timeout for mutations that were awaiting for entities to be returned.
pub mutation_tracker_timeout: Duration,
/// How often the garbage collection process will run.
///
/// Since garbage collection doesn't happen on the whole index, but only on
/// entities that got flagged during search, it is better to run more
/// often than less. `GarbageCollectorConfig::queue_size` can be tweaked
/// to control rate of collection.
pub garbage_collect_interval: Duration,
}
impl Default for StoreConfig {
fn default() -> Self {
StoreConfig {
query_channel_size: 1000,
query_parallelism: 4,
handle_watch_query_channel_size: 100,
chain_events_batch_size: 50,
mutation_tracker_timeout: Duration::from_secs(5),
garbage_collect_interval: Duration::from_secs(13),
}
}
}
impl From<NodeStoreConfig> for StoreConfig {
fn from(proto: NodeStoreConfig) -> Self {
let mut config = StoreConfig::default();
if let Some(v) = proto.query_parallelism {
config.query_parallelism = v as usize;
}
if let Some(index) = &proto.index {
if let Some(gc) = &index.garbage_collector {
if let Some(v) = gc.run_interval_secs {
config.garbage_collect_interval = Duration::from_secs(v as u64);
}
}
}
config
}
}