1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DB_CONFIG_H 17 #define DB_CONFIG_H 18 19 #include <string> 20 21 namespace DocumentDB { 22 class DBConfig final { 23 public: 24 static DBConfig ReadConfig(const std::string &confStr, int &errCode); 25 26 DBConfig() = default; 27 ~DBConfig() = default; 28 29 std::string ToString() const; 30 31 int32_t GetPageSize() const; 32 33 bool operator==(const DBConfig &targetConfig) const; 34 bool operator!=(const DBConfig &targetConfig) const; 35 36 bool CheckPersistenceEqual(const DBConfig &targetConfig) const; 37 38 private: 39 static DBConfig GetDBConfigFromJsonStr(const std::string &confStr, int &errCode); 40 41 std::string configStr_ = {}; 42 int32_t pageSize_ = 4; // 4: default page size k 43 uint32_t redoFlushByTrx_ = 0; 44 uint32_t redoPubBufSize_ = 1024; // 1024: default 1024k buff size 45 int32_t maxConnNum_ = 100; // 100: default max conn 46 uint32_t bufferPoolSize_ = 1024; // 100: default 1024k pool size 47 uint32_t crcCheckEnable_ = 1; 48 }; 49 } // namespace DocumentDB 50 #endif // DB_CONFIG_H