@@ -268,7 +268,7 @@ example service:tcp:127.0.0.1:7878:table_do_my_test"
268268 namespace,
269269 } ) ;
270270 }
271- if parts. len ( ) == 3 {
271+ if parts. len ( ) == 2 || parts . len ( ) == 3 {
272272 let path = parts[ 0 ] . to_string ( ) . into ( ) ;
273273 let spawn_mode = match parts[ 1 ] {
274274 "spawn_blocking" => Ok ( RocksDbSpawnMode :: SpawnBlocking ) ,
@@ -279,14 +279,20 @@ example service:tcp:127.0.0.1:7878:table_do_my_test"
279279 parts[ 1 ]
280280 ) ) ) ,
281281 } ?;
282- let namespace = parts[ 2 ] . to_string ( ) ;
282+ let namespace = if parts. len ( ) == 2 {
283+ DEFAULT_NAMESPACE . to_string ( )
284+ } else {
285+ parts[ 2 ] . to_string ( )
286+ } ;
283287 let storage_config = StorageConfig :: RocksDb { path, spawn_mode } ;
284288 return Ok ( StorageConfigNamespace {
285289 storage_config,
286290 namespace,
287291 } ) ;
288292 }
289- return Err ( Error :: Format ( "We should have one or three parts" . into ( ) ) ) ;
293+ return Err ( Error :: Format (
294+ "We should have one, two or three parts" . into ( ) ,
295+ ) ) ;
290296 }
291297 #[ cfg( feature = "dynamodb" ) ]
292298 if let Some ( s) = input. strip_prefix ( DYNAMO_DB ) {
@@ -958,27 +964,37 @@ fn test_shared_store_config_from_str() {
958964#[ cfg( feature = "rocksdb" ) ]
959965#[ test]
960966fn test_rocks_db_storage_config_from_str ( ) {
967+ assert ! ( StorageConfigNamespace :: from_str( "rocksdb_foo.db" ) . is_err( ) ) ;
961968 assert_eq ! (
962- StorageConfigNamespace :: from_str( "rocksdb:foo.db:block_in_place:chosen_namespace " ) . unwrap( ) ,
969+ StorageConfigNamespace :: from_str( "rocksdb:foo.db" ) . unwrap( ) ,
963970 StorageConfigNamespace {
964971 storage_config: StorageConfig :: RocksDb {
965972 path: "foo.db" . into( ) ,
966- spawn_mode: RocksDbSpawnMode :: BlockInPlace ,
973+ spawn_mode: RocksDbSpawnMode :: SpawnBlocking ,
967974 } ,
968- namespace: "chosen_namespace" . into ( )
975+ namespace: DEFAULT_NAMESPACE . to_string ( )
969976 }
970977 ) ;
971- assert ! ( StorageConfigNamespace :: from_str( "rocksdb_foo.db" ) . is_err( ) ) ;
972978 assert_eq ! (
973- StorageConfigNamespace :: from_str( "rocksdb:foo.db" ) . unwrap( ) ,
979+ StorageConfigNamespace :: from_str( "rocksdb:foo.db:block_in_place " ) . unwrap( ) ,
974980 StorageConfigNamespace {
975981 storage_config: StorageConfig :: RocksDb {
976982 path: "foo.db" . into( ) ,
977- spawn_mode: RocksDbSpawnMode :: SpawnBlocking ,
983+ spawn_mode: RocksDbSpawnMode :: BlockInPlace ,
978984 } ,
979985 namespace: DEFAULT_NAMESPACE . to_string( )
980986 }
981987 ) ;
988+ assert_eq ! (
989+ StorageConfigNamespace :: from_str( "rocksdb:foo.db:block_in_place:chosen_namespace" ) . unwrap( ) ,
990+ StorageConfigNamespace {
991+ storage_config: StorageConfig :: RocksDb {
992+ path: "foo.db" . into( ) ,
993+ spawn_mode: RocksDbSpawnMode :: BlockInPlace ,
994+ } ,
995+ namespace: "chosen_namespace" . into( )
996+ }
997+ ) ;
982998}
983999
9841000#[ cfg( feature = "dynamodb" ) ]
0 commit comments