Skip to content

Commit

Permalink
Replace some "feature = "X"" entries and replace them by "with_X". (#…
Browse files Browse the repository at this point in the history
…2519)

Also, remove the executable status of `build.rs` files.
  • Loading branch information
MathieuDutSik authored Sep 23, 2024
1 parent 71de70b commit 49867a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions linera-storage-service/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

fn main() -> Result<(), Box<dyn std::error::Error>> {
cfg_aliases::cfg_aliases! {
with_rocksdb: { all(feature = "rocksdb") },
with_testing: { any(test, feature = "test") },
with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") },
};
Expand Down
22 changes: 11 additions & 11 deletions linera-storage-service/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use linera_views::{
common::{CommonStoreConfig, ReadableKeyValueStore, WritableKeyValueStore},
memory::MemoryStore,
};
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
use linera_views::{
common::AdminKeyValueStore,
rocks_db::{PathWithGuard, RocksDbStore, RocksDbStoreConfig},
Expand Down Expand Up @@ -41,7 +41,7 @@ pub mod key_value_store {
enum ServiceStoreServerInternal {
Memory(MemoryStore),
/// The RocksDb key value store
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
RocksDb(RocksDbStore),
}

Expand All @@ -64,7 +64,7 @@ impl ServiceStoreServer {
.read_value_bytes(key)
.await
.map_err(|e| Status::unknown(format!("Memory error {:?} at read_value_bytes", e))),
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => store
.read_value_bytes(key)
.await
Expand All @@ -78,7 +78,7 @@ impl ServiceStoreServer {
.contains_key(key)
.await
.map_err(|e| Status::unknown(format!("Memory error {:?} at contains_key", e))),
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => store
.contains_key(key)
.await
Expand All @@ -92,7 +92,7 @@ impl ServiceStoreServer {
.contains_keys(keys)
.await
.map_err(|e| Status::unknown(format!("Memory error {:?} at contains_keys", e))),
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => store
.contains_keys(keys)
.await
Expand All @@ -110,7 +110,7 @@ impl ServiceStoreServer {
Status::unknown(format!("Memory error {:?} at read_multi_values_bytes", e))
})
}
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => {
store.read_multi_values_bytes(keys).await.map_err(|e| {
Status::unknown(format!("RocksDB error {:?} at read_multi_values_bytes", e))
Expand All @@ -126,7 +126,7 @@ impl ServiceStoreServer {
Status::unknown(format!("Memory error {:?} at find_keys_by_prefix", e))
})
}
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => {
store.find_keys_by_prefix(key_prefix).await.map_err(|e| {
Status::unknown(format!("RocksDB error {:?} at find_keys_by_prefix", e))
Expand All @@ -146,7 +146,7 @@ impl ServiceStoreServer {
.map_err(|e| {
Status::unknown(format!("Memory error {:?} at find_key_values_by_prefix", e))
}),
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => store
.find_key_values_by_prefix(key_prefix)
.await
Expand All @@ -165,7 +165,7 @@ impl ServiceStoreServer {
.write_batch(batch)
.await
.map_err(|e| Status::unknown(format!("Memory error {:?} at write_batch", e))),
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerInternal::RocksDb(store) => store
.write_batch(batch)
.await
Expand Down Expand Up @@ -239,7 +239,7 @@ enum ServiceStoreServerOptions {
endpoint: String,
},

#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
#[command(name = "rocksdb")]
RocksDb {
#[arg(long = "path")]
Expand Down Expand Up @@ -579,7 +579,7 @@ async fn main() {
let store = ServiceStoreServerInternal::Memory(store);
(store, endpoint)
}
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
ServiceStoreServerOptions::RocksDb { path, endpoint } => {
let path_buf = path.into();
let path_with_guard = PathWithGuard::new(path_buf);
Expand Down
4 changes: 2 additions & 2 deletions linera-views/src/backends/scylla_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,10 +913,10 @@ impl ScyllaDbStore {

fn from_inner(simple_store: ScyllaDbStoreInternal, cache_size: usize) -> ScyllaDbStore {
let store = JournalingKeyValueStore::new(simple_store);
#[cfg(feature = "metrics")]
#[cfg(with_metrics)]
let store = MeteredStore::new(&SCYLLA_DB_METRICS, store);
let store = LruCachingStore::new(store, cache_size);
#[cfg(feature = "metrics")]
#[cfg(with_metrics)]
let store = MeteredStore::new(&LRU_CACHING_METRICS, store);
Self { store }
}
Expand Down
12 changes: 6 additions & 6 deletions linera-views/tests/admin_tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "dynamodb")]
#[cfg(with_dynamodb)]
use linera_views::dynamo_db::DynamoDbStore;
#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
use linera_views::rocks_db::RocksDbStore;
#[cfg(feature = "scylladb")]
#[cfg(with_scylladb)]
use linera_views::scylla_db::ScyllaDbStore;
use linera_views::{memory::MemoryStore, test_utils::admin_test};

Expand All @@ -14,19 +14,19 @@ async fn admin_test_memory() {
admin_test::<MemoryStore>().await;
}

#[cfg(feature = "rocksdb")]
#[cfg(with_rocksdb)]
#[tokio::test]
async fn admin_test_rocks_db() {
admin_test::<RocksDbStore>().await;
}

#[cfg(feature = "dynamodb")]
#[cfg(with_dynamodb)]
#[tokio::test]
async fn admin_test_dynamo_db() {
admin_test::<DynamoDbStore>().await;
}

#[cfg(feature = "scylladb")]
#[cfg(with_scylladb)]
#[tokio::test]
async fn admin_test_scylla_db() {
admin_test::<ScyllaDbStore>().await;
Expand Down

0 comments on commit 49867a3

Please sign in to comment.