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)]
10pub struct CommonStorageOptions {
11 #[arg(long, global = true)]
13 pub storage_max_concurrent_queries: Option<usize>,
14
15 #[arg(long, default_value = "10", global = true)]
17 pub storage_max_stream_queries: usize,
18
19 #[arg(long, default_value = "10000000", global = true)]
21 pub storage_max_cache_size: usize,
22
23 #[arg(long, default_value = "1000000", global = true)]
25 pub storage_max_value_entry_size: usize,
26
27 #[arg(long, default_value = "1000000", global = true)]
29 pub storage_max_find_keys_entry_size: usize,
30
31 #[arg(long, default_value = "1000000", global = true)]
33 pub storage_max_find_key_values_entry_size: usize,
34
35 #[arg(long, default_value = "1000", global = true)]
37 pub storage_max_cache_entries: usize,
38
39 #[arg(long, default_value = "10000000", global = true)]
41 pub storage_max_cache_value_size: usize,
42
43 #[arg(long, default_value = "10000000", global = true)]
45 pub storage_max_cache_find_keys_size: usize,
46
47 #[arg(long, default_value = "10000000", global = true)]
49 pub storage_max_cache_find_key_values_size: usize,
50
51 #[arg(long, default_value = "1000", global = true)]
53 pub blob_cache_size: usize,
54
55 #[arg(long, default_value = "1000", global = true)]
57 pub confirmed_block_cache_size: usize,
58
59 #[arg(long, default_value = "1000", global = true)]
61 pub certificate_cache_size: usize,
62
63 #[arg(long, default_value = "1000", global = true)]
65 pub certificate_raw_cache_size: usize,
66
67 #[arg(long, default_value = "1000", global = true)]
69 pub event_cache_size: usize,
70
71 #[arg(long, default_value = "1000", global = true)]
73 pub block_hash_by_height_cache_size: usize,
74
75 #[arg(long, default_value = "1000", global = true)]
77 pub event_block_height_cache_size: usize,
78
79 #[arg(long, default_value_t = DEFAULT_CLEANUP_INTERVAL_SECS, global = true)]
81 pub cache_cleanup_interval_secs: u64,
82
83 #[arg(long, default_value = "1", global = true)]
85 pub storage_replication_factor: u32,
86}
87
88impl CommonStorageOptions {
89 pub fn with_defaults() -> Self {
91 use clap::Parser as _;
92 Self::parse_from(std::iter::empty::<String>())
93 }
94
95 pub fn storage_cache_config(&self) -> StorageCacheConfig {
97 StorageCacheConfig {
98 blob_cache_size: self.blob_cache_size,
99 confirmed_block_cache_size: self.confirmed_block_cache_size,
100 certificate_cache_size: self.certificate_cache_size,
101 certificate_raw_cache_size: self.certificate_raw_cache_size,
102 event_cache_size: self.event_cache_size,
103 block_hash_by_height_cache_size: self.block_hash_by_height_cache_size,
104 event_block_height_cache_size: self.event_block_height_cache_size,
105 cache_cleanup_interval_secs: self.cache_cleanup_interval_secs,
106 }
107 }
108
109 pub fn views_storage_cache_config(&self) -> ViewsStorageCacheConfig {
111 ViewsStorageCacheConfig {
112 max_cache_size: self.storage_max_cache_size,
113 max_value_entry_size: self.storage_max_value_entry_size,
114 max_find_keys_entry_size: self.storage_max_find_keys_entry_size,
115 max_find_key_values_entry_size: self.storage_max_find_key_values_entry_size,
116 max_cache_entries: self.storage_max_cache_entries,
117 max_cache_value_size: self.storage_max_cache_value_size,
118 max_cache_find_keys_size: self.storage_max_cache_find_keys_size,
119 max_cache_find_key_values_size: self.storage_max_cache_find_key_values_size,
120 }
121 }
122}