Repository: robustmq/robustmq (language: rust)

Issue:
[MINOR][Chore][Subtask] `ShardConfig` should be stored somewhere when creating a new rocksdb shard
### Have you checked the documentation for submitting an Issue?

- [x] Yes.

### What type of enhancement is this?

Chore

### What does the enhancement do?

Store the `ShardConfig` object, which is one of the arguments of the `create_shard` method, in rocksdb.  

### Implementation challenges

_No response_

### Are you willing to submit PR?

- [x] Yes. I would be willing to submit a PR with guidance from the RobustMQ community to improve.
- [ ] No. I cannot submit a PR at this time.


Discussion / hints:

Fix patch:
diff --git a/src/storage-adapter/src/rocksdb/mod.rs b/src/storage-adapter/src/rocksdb/mod.rs
index b8809f3b4..df0a5190a 100644
--- a/src/storage-adapter/src/rocksdb/mod.rs
+++ b/src/storage-adapter/src/rocksdb/mod.rs
@@ -19,6 +19,7 @@ use common_base::error::common::CommonError;
 use dashmap::DashMap;
 use metadata_struct::adapter::{read_config::ReadConfig, record::Record};
 use rocksdb_engine::RocksDBEngine;
+use serde::{Deserialize, Serialize};
 use tokio::{
     select,
     sync::{
@@ -55,6 +56,13 @@ struct ThreadWriteHandle {
     stop_sender: broadcast::Sender<bool>,
 }
 
+#[derive(Serialize, Deserialize)]
+struct ShardConfigStore {
+    namespace: String,
+    shard_name: String,
+    shard_config: ShardConfig,
+}
+
 impl WriteThreadData {
     fn new(
         namespace: String,
@@ -130,6 +138,11 @@ impl RocksDBStorageAdapter {
     pub fn group_record_offsets_key_prefix<S1: Display>(group: &S1) -> String {
         format!("/group/{}/", group)
     }
+
+    #[inline(always)]
+    pub fn shard_config_key<S1: Display>(namespace: &S1, shard: &S1) -> String {
+        format!("/shard_config/{}/{}", namespace, shard)
+    }
 }
 
 impl RocksDBStorageAdapter {
@@ -310,7 +323,7 @@ impl StorageAdapter for RocksDBStorageAdapter {
         &self,
         namespace: String,
         shard_name: String,
-        _: ShardConfig,
+        shard_config: ShardConfig,
     ) -> Result<(), CommonError> {
         let cf = self.db.cf_handle(DB_COLUMN_FAMILY).unwrap();
 
@@ -328,7 +341,21 @@ impl StorageAdapter for RocksDBStorageAdapter {
             )));
         }
 
-        self.db.write(cf, shard_offset_key.as_str(), &0_u64)
+        self.db
+            .write(cf.clone(), shard_offset_key.as_str(), &0_u64)?;
+
+        let shard_config_store = ShardConfigStore {
+            namespace: namespace.clone(),
+            shard_name: shard_name.clone(),
+            shard_config,
+        };
+
+        // store shard config
+        self.db.write(
+            cf,
+            Self::shard_config_key(&namespace, &shard_name).as_str(),
+            &serde_json::to_vec(&shard_config_store)?,
+        )
     }
 
     async fn delete_shard(&self, namespace: String, shard_name: String) -> Result<(), CommonError> {


Test patch: