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     ~DBConfig() = default;
26 
27     std::string ToString() const;
28 
29     int32_t GetPageSize() const;
30 
31     bool operator==(const DBConfig &targetConfig) const;
32     bool operator!=(const DBConfig &targetConfig) const;
33 
34     bool CheckPersistenceEqual(const DBConfig &targetConfig) const;
35 
36 private:
37     static DBConfig GetDBConfigFromJsonStr(const std::string &confStr, int &errCode);
38     DBConfig() = default;
39     DBConfig(const DBConfig&) = default;
40     DBConfig(DBConfig&&) = default;
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     uint32_t shareModeEnable_ = 0;
49 };
50 } // namespace DocumentDB
51 #endif // DB_CONFIG_H