-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathscylla_db.rs
More file actions
120 lines (98 loc) · 4.47 KB
/
Copy pathscylla_db.rs
File metadata and controls
120 lines (98 loc) · 4.47 KB
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
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use linera_views::{
lru_prefix_cache::StorageCacheConfig,
scylla_db::{ScyllaDbDatabase, ScyllaDbStoreConfig, ScyllaDbStoreInternalConfig},
store::KeyValueDatabase,
};
use crate::{
common::IndexerError,
runner::{IndexerConfig, Runner},
};
#[derive(clap::Parser, Clone, Debug)]
#[command(version = linera_version::VersionInfo::default_clap_str())]
pub struct ScyllaDbConfig {
/// ScyllaDB address
#[arg(long, default_value = "localhost:9042")]
pub uri: String,
#[arg(long, default_value = "linera")]
pub table: String,
/// The maximal number of simultaneous queries to the database
#[arg(long)]
max_concurrent_queries: Option<usize>,
/// The maximal number of simultaneous stream queries to the database
#[arg(long, default_value = "10")]
pub max_stream_queries: usize,
/// The maximal memory used in the storage cache in bytes.
#[arg(long, default_value = "10000000")]
pub max_cache_size: usize,
/// The maximal size of a value entry in the storage cache in bytes.
#[arg(long, default_value = "1000000")]
pub max_value_entry_size: usize,
/// The maximal size of a find-keys entry in the storage cache in bytes.
#[arg(long, default_value = "1000000")]
pub max_find_keys_entry_size: usize,
/// The maximal size of a find-key-values entry in the storage cache in bytes.
#[arg(long, default_value = "1000000")]
pub max_find_key_values_entry_size: usize,
/// The maximal number of entries in the storage cache.
#[arg(long, default_value = "1000")]
pub max_cache_entries: usize,
/// The maximal memory used in the value cache in bytes.
#[arg(long, default_value = "10000000")]
pub max_cache_value_size: usize,
/// The maximal memory used in the find_keys_by_prefix cache in bytes.
#[arg(long, default_value = "10000000")]
pub max_cache_find_keys_size: usize,
/// The maximal memory used in the find_key_values_by_prefix cache in bytes.
#[arg(long, default_value = "10000000")]
pub max_cache_find_key_values_size: usize,
/// The maximal number of entries in the blob cache.
#[arg(long, default_value = "1000")]
pub blob_cache_size: usize,
/// The maximal number of entries in the confirmed block cache.
#[arg(long, default_value = "1000")]
pub confirmed_block_cache_size: usize,
/// The maximal number of entries in the assembled certificate cache.
#[arg(long, default_value = "1000")]
pub certificate_cache_size: usize,
/// The maximal number of entries in the raw certificate cache.
#[arg(long, default_value = "1000")]
pub certificate_raw_cache_size: usize,
/// The maximal number of entries in the event cache.
#[arg(long, default_value = "1000")]
pub event_cache_size: usize,
/// The replication factor for the keyspace
#[arg(long, default_value = "1")]
pub replication_factor: u32,
}
pub type ScyllaDbRunner = Runner<ScyllaDbDatabase, ScyllaDbConfig>;
impl ScyllaDbRunner {
pub async fn load() -> Result<Self, IndexerError> {
let config = <IndexerConfig<ScyllaDbConfig> as clap::Parser>::parse();
let storage_cache_config = StorageCacheConfig {
max_cache_size: config.client.max_cache_size,
max_value_entry_size: config.client.max_value_entry_size,
max_find_keys_entry_size: config.client.max_find_keys_entry_size,
max_find_key_values_entry_size: config.client.max_find_key_values_entry_size,
max_cache_entries: config.client.max_cache_entries,
max_cache_value_size: config.client.max_cache_value_size,
max_cache_find_keys_size: config.client.max_cache_find_keys_size,
max_cache_find_key_values_size: config.client.max_cache_find_key_values_size,
};
let inner_config = ScyllaDbStoreInternalConfig {
uri: config.client.uri.clone(),
max_stream_queries: config.client.max_stream_queries,
max_concurrent_queries: config.client.max_concurrent_queries,
replication_factor: config.client.replication_factor,
tuning_options: Default::default(),
};
let store_config = ScyllaDbStoreConfig {
inner_config,
storage_cache_config,
};
let namespace = config.client.table.clone();
let database = ScyllaDbDatabase::connect(&store_config, &namespace).await?;
Self::new(config, database).await
}
}