1 /* 2 * Copyright (c) 2021 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 KV_DB_PRAGMA_H 17 #define KV_DB_PRAGMA_H 18 19 #include <vector> 20 #include <string> 21 #include <functional> 22 23 #include "store_types.h" 24 #include "query_sync_object.h" 25 26 namespace DistributedDB { 27 enum : int { 28 PRAGMA_AUTO_SYNC = 1, 29 PRAGMA_SYNC_DEVICES, 30 PRAGMA_RM_DEVICE_DATA, // remove the device data synced from remote by device name 31 PRAGMA_PERFORMANCE_ANALYSIS_GET_REPORT, 32 PRAGMA_PERFORMANCE_ANALYSIS_OPEN, 33 PRAGMA_PERFORMANCE_ANALYSIS_CLOSE, 34 PRAGMA_PERFORMANCE_ANALYSIS_SET_REPORTFILENAME, 35 PRAGMA_GET_IDENTIFIER_OF_DEVICE, 36 PRAGMA_GET_DEVICE_IDENTIFIER_OF_ENTRY, 37 PRAGMA_GET_QUEUED_SYNC_SIZE, 38 PRAGMA_SET_QUEUED_SYNC_LIMIT, 39 PRAGMA_GET_QUEUED_SYNC_LIMIT, 40 PRAGMA_SET_WIPE_POLICY, 41 PRAGMA_PUBLISH_LOCAL, 42 PRAGMA_UNPUBLISH_SYNC, 43 PRAGMA_SET_AUTO_LIFE_CYCLE, 44 PRAGMA_RESULT_SET_CACHE_MODE, 45 PRAGMA_RESULT_SET_CACHE_MAX_SIZE, 46 PRAGMA_TRIGGER_TO_MIGRATE_DATA, 47 PRAGMA_REMOTE_PUSH_FINISHED_NOTIFY, 48 PRAGMA_SET_SYNC_RETRY, 49 PRAGMA_ADD_EQUAL_IDENTIFIER, 50 PRAGMA_INTERCEPT_SYNC_DATA, 51 PRAGMA_SUBSCRIBE_QUERY, 52 PRAGMA_SET_MAX_LOG_LIMIT, 53 PRAGMA_EXEC_CHECKPOINT, 54 }; 55 56 struct PragmaSync { 57 PragmaSync(const std::vector<std::string> &devices, int mode, const QuerySyncObject &query, 58 const std::function<void(const std::map<std::string, int> &devicesMap)> &onComplete, 59 bool wait = false) 60 : devices_(devices), 61 mode_(mode), 62 onComplete_(onComplete), 63 wait_(wait), 64 isQuerySync_(true), 65 query_(query) 66 { 67 } 68 69 PragmaSync(const std::vector<std::string> &devices, int mode, 70 const std::function<void(const std::map<std::string, int> &devicesMap)> &onComplete, 71 bool wait = false) 72 : devices_(devices), 73 mode_(mode), 74 onComplete_(onComplete), 75 wait_(wait), 76 isQuerySync_(false), 77 query_(Query::Select()) 78 { 79 } 80 81 std::vector<std::string> devices_; 82 int mode_; 83 std::function<void(const std::map<std::string, int> &devicesMap)> onComplete_; 84 bool wait_; 85 bool isQuerySync_; 86 QuerySyncObject query_; 87 }; 88 89 struct PragmaRemotePushNotify { PragmaRemotePushNotifyPragmaRemotePushNotify90 explicit PragmaRemotePushNotify(RemotePushFinishedNotifier notifier) : notifier_(notifier) {} 91 92 RemotePushFinishedNotifier notifier_; 93 }; 94 95 struct PragmaSetEqualIdentifier { PragmaSetEqualIdentifierPragmaSetEqualIdentifier96 PragmaSetEqualIdentifier(const std::string &identifier, const std::vector<std::string> &targets) 97 : identifier_(identifier), 98 targets_(targets) {} 99 100 std::string identifier_; 101 std::vector<std::string> targets_; 102 }; 103 } // namespace DistributedDB 104 105 #endif // KV_DB_PRAGMA_H 106