linera_storage_runtime/
common_options.rs1use linera_storage::{StorageCacheConfig, DEFAULT_CLEANUP_INTERVAL_SECS};
5use linera_views::lru_prefix_cache::StorageCacheConfig as ViewsStorageCacheConfig;
6
7#[derive(Clone, Debug, clap::Parser)]
8pub struct CommonStorageOptions {
9 #[arg(long, global = true)]
11 pub storage_max_concurrent_queries: Option<usize>,
12
13 #[arg(long, default_value = "10", global = true)]
15 pub storage_max_stream_queries: usize,
16
17 #[arg(long, default_value = "10000000", global = true)]
19 pub storage_max_cache_size: usize,
20
21 #[arg(long, default_value = "1000000", global = true)]
23 pub storage_max_value_entry_size: usize,
24
25 #[arg(long, default_value = "1000000", global = true)]
27 pub storage_max_find_keys_entry_size: usize,
28
29 #[arg(long, default_value = "1000000", global = true)]
31 pub storage_max_find_key_values_entry_size: usize,
32
33 #[arg(long, default_value = "1000", global = true)]
35 pub storage_max_cache_entries: usize,
36
37 #[arg(long, default_value = "10000000", global = true)]
39 pub storage_max_cache_value_size: usize,
40
41 #[arg(long, default_value = "10000000", global = true)]
43 pub storage_max_cache_find_keys_size: usize,
44
45 #[arg(long, default_value = "10000000", global = true)]
47 pub storage_max_cache_find_key_values_size: usize,
48
49 #[arg(long, default_value = "1000", global = true)]
51 pub blob_cache_size: usize,
52
53 #[arg(long, default_value = "1000", global = true)]
55 pub confirmed_block_cache_size: usize,
56
57 #[arg(long, default_value = "1000", global = true)]
59 pub certificate_cache_size: usize,
60
61 #[arg(long, default_value = "1000", global = true)]
63 pub certificate_raw_cache_size: usize,
64
65 #[arg(long, default_value = "1000", global = true)]
67 pub event_cache_size: usize,
68
69 #[arg(long, default_value_t = DEFAULT_CLEANUP_INTERVAL_SECS, global = true)]
71 pub cache_cleanup_interval_secs: u64,
72
73 #[arg(long, default_value = "1", global = true)]
75 pub storage_replication_factor: u32,
76}
77
78impl CommonStorageOptions {
79 pub fn with_defaults() -> Self {
80 use clap::Parser as _;
81 Self::parse_from(std::iter::empty::<String>())
82 }
83
84 pub fn storage_cache_config(&self) -> StorageCacheConfig {
85 StorageCacheConfig {
86 blob_cache_size: self.blob_cache_size,
87 confirmed_block_cache_size: self.confirmed_block_cache_size,
88 certificate_cache_size: self.certificate_cache_size,
89 certificate_raw_cache_size: self.certificate_raw_cache_size,
90 event_cache_size: self.event_cache_size,
91 cache_cleanup_interval_secs: self.cache_cleanup_interval_secs,
92 }
93 }
94
95 pub fn views_storage_cache_config(&self) -> ViewsStorageCacheConfig {
96 ViewsStorageCacheConfig {
97 max_cache_size: self.storage_max_cache_size,
98 max_value_entry_size: self.storage_max_value_entry_size,
99 max_find_keys_entry_size: self.storage_max_find_keys_entry_size,
100 max_find_key_values_entry_size: self.storage_max_find_key_values_entry_size,
101 max_cache_entries: self.storage_max_cache_entries,
102 max_cache_value_size: self.storage_max_cache_value_size,
103 max_cache_find_keys_size: self.storage_max_cache_find_keys_size,
104 max_cache_find_key_values_size: self.storage_max_cache_find_key_values_size,
105 }
106 }
107}