@@ -14,13 +14,15 @@ use linera_storage_service::{
1414 common:: { ServiceStoreConfig , ServiceStoreInternalConfig } ,
1515} ;
1616#[ cfg( feature = "dynamodb" ) ]
17- use linera_views:: dynamo_db:: { DynamoDbStore , DynamoDbStoreConfig } ;
17+ use linera_views:: dynamo_db:: { DynamoDbStore , DynamoDbStoreConfig , DynamoDbStoreInternalConfig } ;
1818#[ cfg( feature = "rocksdb" ) ]
19- use linera_views:: rocks_db:: { PathWithGuard , RocksDbSpawnMode , RocksDbStore , RocksDbStoreConfig } ;
19+ use linera_views:: rocks_db:: {
20+ PathWithGuard , RocksDbSpawnMode , RocksDbStore , RocksDbStoreConfig , RocksDbStoreInternalConfig ,
21+ } ;
2022use linera_views:: {
2123 lru_caching:: StorageCacheConfig ,
2224 memory:: { MemoryStore , MemoryStoreConfig } ,
23- store:: { CommonStoreConfig , KeyValueStore } ,
25+ store:: KeyValueStore ,
2426} ;
2527use serde:: { Deserialize , Serialize } ;
2628use tracing:: error;
3234} ;
3335#[ cfg( feature = "scylladb" ) ]
3436use {
35- linera_views:: scylla_db:: { ScyllaDbStore , ScyllaDbStoreConfig } ,
37+ linera_views:: scylla_db:: { ScyllaDbStore , ScyllaDbStoreConfig , ScyllaDbStoreInternalConfig } ,
3638 std:: num:: NonZeroU16 ,
3739 tracing:: debug,
3840} ;
@@ -65,36 +67,30 @@ pub struct CommonStorageOptions {
6567}
6668
6769impl CommonStorageOptions {
68- pub fn common_store_config ( & self ) -> CommonStoreConfig {
69- let storage_cache_config = StorageCacheConfig {
70+ pub fn storage_cache_config ( & self ) -> StorageCacheConfig {
71+ StorageCacheConfig {
7072 max_cache_size : self . storage_max_cache_size ,
7173 max_entry_size : self . storage_max_entry_size ,
7274 max_cache_entries : self . storage_max_cache_entries ,
73- } ;
74- CommonStoreConfig {
75- storage_cache_config,
76- max_concurrent_queries : self . storage_max_concurrent_queries ,
77- max_stream_queries : self . storage_max_stream_queries ,
78- replication_factor : self . storage_replication_factor ,
7975 }
8076 }
8177}
8278
8379/// The configuration of the key value store in use.
8480#[ derive( Clone , Debug , Deserialize , Serialize ) ]
8581pub enum StoreConfig {
86- /// The storage service key-value store
87- #[ cfg( feature = "storage-service" ) ]
88- Service {
89- config : ServiceStoreConfig ,
90- namespace : String ,
91- } ,
9282 /// The memory key value store
9383 Memory {
9484 config : MemoryStoreConfig ,
9585 namespace : String ,
9686 genesis_path : PathBuf ,
9787 } ,
88+ /// The storage service key-value store
89+ #[ cfg( feature = "storage-service" ) ]
90+ Service {
91+ config : ServiceStoreConfig ,
92+ namespace : String ,
93+ } ,
9894 /// The RocksDB key value store
9995 #[ cfg( feature = "rocksdb" ) ]
10096 RocksDb {
@@ -124,18 +120,18 @@ pub enum StoreConfig {
124120#[ derive( Clone , Debug ) ]
125121#[ cfg_attr( any( test) , derive( Eq , PartialEq ) ) ]
126122pub enum InnerStorageConfig {
127- /// The storage service description.
128- #[ cfg( feature = "storage-service" ) ]
129- Service {
130- /// The endpoint used.
131- endpoint : String ,
132- } ,
133123 /// The memory description.
134124 Memory {
135125 /// The path to the genesis configuration. This is needed because we reinitialize
136126 /// memory databases from the genesis config everytime.
137127 genesis_path : PathBuf ,
138128 } ,
129+ /// The storage service description.
130+ #[ cfg( feature = "storage-service" ) ]
131+ Service {
132+ /// The endpoint used.
133+ endpoint : String ,
134+ } ,
139135 /// The RocksDB description.
140136 #[ cfg( feature = "rocksdb" ) ]
141137 RocksDb {
@@ -430,25 +426,11 @@ impl StorageConfig {
430426 & self ,
431427 options : & CommonStorageOptions ,
432428 ) -> Result < StoreConfig , anyhow:: Error > {
433- let common_config = options. common_store_config ( ) ;
434429 let namespace = self . namespace . clone ( ) ;
435430 match & self . inner_storage_config {
436- #[ cfg( feature = "storage-service" ) ]
437- InnerStorageConfig :: Service { endpoint } => {
438- let endpoint = endpoint. clone ( ) ;
439- let inner_config = ServiceStoreInternalConfig {
440- endpoint,
441- common_config : common_config. reduced ( ) ,
442- } ;
443- let config = ServiceStoreConfig {
444- inner_config,
445- storage_cache_config : common_config. storage_cache_config ,
446- } ;
447- Ok ( StoreConfig :: Service { config, namespace } )
448- }
449431 InnerStorageConfig :: Memory { genesis_path } => {
450432 let config = MemoryStoreConfig {
451- common_config : common_config . reduced ( ) ,
433+ max_stream_queries : options . storage_max_stream_queries ,
452434 } ;
453435 let genesis_path = genesis_path. clone ( ) ;
454436 Ok ( StoreConfig :: Memory {
@@ -457,21 +439,58 @@ impl StorageConfig {
457439 genesis_path,
458440 } )
459441 }
442+ #[ cfg( feature = "storage-service" ) ]
443+ InnerStorageConfig :: Service { endpoint } => {
444+ let inner_config = ServiceStoreInternalConfig {
445+ endpoint : endpoint. clone ( ) ,
446+ max_concurrent_queries : options. storage_max_concurrent_queries ,
447+ max_stream_queries : options. storage_max_stream_queries ,
448+ } ;
449+ let config = ServiceStoreConfig {
450+ inner_config,
451+ storage_cache_config : options. storage_cache_config ( ) ,
452+ } ;
453+ Ok ( StoreConfig :: Service { config, namespace } )
454+ }
460455 #[ cfg( feature = "rocksdb" ) ]
461456 InnerStorageConfig :: RocksDb { path, spawn_mode } => {
462- let path_buf = path. to_path_buf ( ) ;
463- let path_with_guard = PathWithGuard :: new ( path_buf) ;
464- let config = RocksDbStoreConfig :: new ( * spawn_mode, path_with_guard, common_config) ;
457+ let path_with_guard = PathWithGuard :: new ( path. to_path_buf ( ) ) ;
458+ let inner_config = RocksDbStoreInternalConfig {
459+ spawn_mode : * spawn_mode,
460+ path_with_guard,
461+ max_stream_queries : options. storage_max_stream_queries ,
462+ } ;
463+ let config = RocksDbStoreConfig {
464+ inner_config,
465+ storage_cache_config : options. storage_cache_config ( ) ,
466+ } ;
465467 Ok ( StoreConfig :: RocksDb { config, namespace } )
466468 }
467469 #[ cfg( feature = "dynamodb" ) ]
468470 InnerStorageConfig :: DynamoDb { use_dynamodb_local } => {
469- let config = DynamoDbStoreConfig :: new ( * use_dynamodb_local, common_config) ;
471+ let inner_config = DynamoDbStoreInternalConfig {
472+ use_dynamodb_local : * use_dynamodb_local,
473+ max_concurrent_queries : options. storage_max_concurrent_queries ,
474+ max_stream_queries : options. storage_max_stream_queries ,
475+ } ;
476+ let config = DynamoDbStoreConfig {
477+ inner_config,
478+ storage_cache_config : options. storage_cache_config ( ) ,
479+ } ;
470480 Ok ( StoreConfig :: DynamoDb { config, namespace } )
471481 }
472482 #[ cfg( feature = "scylladb" ) ]
473483 InnerStorageConfig :: ScyllaDb { uri } => {
474- let config = ScyllaDbStoreConfig :: new ( uri. to_string ( ) , common_config) ;
484+ let inner_config = ScyllaDbStoreInternalConfig {
485+ uri : uri. clone ( ) ,
486+ max_stream_queries : options. storage_max_stream_queries ,
487+ max_concurrent_queries : options. storage_max_concurrent_queries ,
488+ replication_factor : options. storage_replication_factor ,
489+ } ;
490+ let config = ScyllaDbStoreConfig {
491+ inner_config,
492+ storage_cache_config : options. storage_cache_config ( ) ,
493+ } ;
475494 Ok ( StoreConfig :: ScyllaDb { config, namespace } )
476495 }
477496 #[ cfg( all( feature = "rocksdb" , feature = "scylladb" ) ) ]
@@ -480,12 +499,27 @@ impl StorageConfig {
480499 spawn_mode,
481500 uri,
482501 } => {
483- let first_config = RocksDbStoreConfig :: new (
484- * spawn_mode,
485- path_with_guard. clone ( ) ,
486- common_config. clone ( ) ,
487- ) ;
488- let second_config = ScyllaDbStoreConfig :: new ( uri. to_string ( ) , common_config) ;
502+ let inner_config = RocksDbStoreInternalConfig {
503+ spawn_mode : * spawn_mode,
504+ path_with_guard : path_with_guard. clone ( ) ,
505+ max_stream_queries : options. storage_max_stream_queries ,
506+ } ;
507+ let first_config = RocksDbStoreConfig {
508+ inner_config,
509+ storage_cache_config : options. storage_cache_config ( ) ,
510+ } ;
511+
512+ let inner_config = ScyllaDbStoreInternalConfig {
513+ uri : uri. clone ( ) ,
514+ max_stream_queries : options. storage_max_stream_queries ,
515+ max_concurrent_queries : options. storage_max_concurrent_queries ,
516+ replication_factor : options. storage_replication_factor ,
517+ } ;
518+ let second_config = ScyllaDbStoreConfig {
519+ inner_config,
520+ storage_cache_config : options. storage_cache_config ( ) ,
521+ } ;
522+
489523 let config = DualStoreConfig {
490524 first_config,
491525 second_config,
@@ -578,9 +612,8 @@ impl StoreConfig {
578612 namespace,
579613 genesis_path,
580614 } => {
581- let store_config = MemoryStoreConfig :: new ( config. common_config . max_stream_queries ) ;
582615 let mut storage = DbStorage :: < MemoryStore , _ > :: maybe_create_and_connect (
583- & store_config ,
616+ & config ,
584617 & namespace,
585618 wasm_runtime,
586619 )
0 commit comments