Use KeyValueSyncInterface and BinlogInterface in TdDb.

GitOrigin-RevId: 6e038ac9124855660da72fc64ec131a6e8211055
This commit is contained in:
levlam 2019-01-07 02:44:29 +03:00
parent a2a7b44ad6
commit 424faa44f3
10 changed files with 30 additions and 25 deletions

View File

@ -7,6 +7,7 @@
#include "td/actor/actor.h"
#include "td/db/binlog/Binlog.h"
#include "td/db/binlog/ConcurrentBinlog.h"
#include "td/db/BinlogKeyValue.h"
#include "td/db/SeqKeyValue.h"
#include "td/db/SqliteDb.h"

View File

@ -6,8 +6,6 @@
//
#include "td/telegram/DhCache.h"
#include "td/db/Pmc.h"
#include "td/telegram/Global.h"
#include "td/telegram/TdDb.h"

View File

@ -16,8 +16,6 @@
#include "td/actor/PromiseFuture.h"
#include "td/db/Pmc.h"
#include "td/utils/format.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/tl_helpers.h"

View File

@ -9,7 +9,6 @@
#include "td/telegram/Global.h"
#include "td/telegram/TdDb.h"
#include "td/db/Pmc.h"
#include "td/db/SqliteKeyValueAsync.h"
#include "td/utils/logging.h"

View File

@ -15,6 +15,7 @@
#include "td/actor/MultiPromise.h"
#include "td/db/binlog/ConcurrentBinlog.h"
#include "td/db/BinlogKeyValue.h"
#include "td/db/SqliteKeyValue.h"
#include "td/db/SqliteKeyValueAsync.h"
@ -135,25 +136,27 @@ std::shared_ptr<SqliteConnectionSafe> &TdDb::get_sqlite_connection_safe() {
return sql_connection_;
}
ConcurrentBinlog *TdDb::get_binlog() {
BinlogInterface *TdDb::get_binlog() {
CHECK(binlog_);
return binlog_.get();
}
std::shared_ptr<KeyValueSyncInterface> TdDb::get_binlog_pmc_shared() {
CHECK(binlog_pmc_);
return binlog_pmc_;
}
std::shared_ptr<KeyValueSyncInterface> TdDb::get_config_pmc_shared() {
CHECK(config_pmc_);
return config_pmc_;
}
BinlogKeyValue<ConcurrentBinlog> *TdDb::get_binlog_pmc() {
KeyValueSyncInterface *TdDb::get_binlog_pmc() {
CHECK(binlog_pmc_);
return binlog_pmc_.get();
}
BinlogKeyValue<ConcurrentBinlog> *TdDb::get_config_pmc() {
KeyValueSyncInterface *TdDb::get_config_pmc() {
CHECK(config_pmc_);
return config_pmc_.get();
}

View File

@ -9,9 +9,8 @@
#include "td/telegram/TdParameters.h"
#include "td/db/binlog/Binlog.h"
#include "td/db/binlog/BinlogInterface.h"
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/ConcurrentBinlog.h"
#include "td/db/BinlogKeyValue.h"
#include "td/db/DbKey.h"
#include "td/db/KeyValueSyncInterface.h"
@ -25,17 +24,20 @@
namespace td {
class SqliteConnectionSafe;
class SqliteKeyValueSafe;
class SqliteKeyValueAsyncInterface;
class SqliteKeyValue;
class MessagesDbSyncInterface;
class MessagesDbSyncSafeInterface;
class MessagesDbAsyncInterface;
template <class BinlogT>
class BinlogKeyValue;
class ConcurrentBinlog;
class DialogDbSyncInterface;
class DialogDbSyncSafeInterface;
class DialogDbAsyncInterface;
class FileDbInterface;
class MessagesDbSyncInterface;
class MessagesDbSyncSafeInterface;
class MessagesDbAsyncInterface;
class SqliteConnectionSafe;
class SqliteKeyValueSafe;
class SqliteKeyValueAsyncInterface;
class SqliteKeyValue;
class TdDb {
public:
@ -66,12 +68,12 @@ class TdDb {
std::shared_ptr<FileDbInterface> get_file_db_shared();
std::shared_ptr<SqliteConnectionSafe> &get_sqlite_connection_safe();
ConcurrentBinlog *get_binlog();
BinlogInterface *get_binlog();
std::shared_ptr<KeyValueSyncInterface> get_binlog_pmc_shared();
std::shared_ptr<KeyValueSyncInterface> get_config_pmc_shared();
BinlogKeyValue<ConcurrentBinlog> *get_binlog_pmc();
BinlogKeyValue<ConcurrentBinlog> *get_config_pmc();
KeyValueSyncInterface *get_binlog_pmc();
KeyValueSyncInterface *get_config_pmc();
SqliteKeyValue *get_sqlite_sync_pmc();
SqliteKeyValueAsyncInterface *get_sqlite_pmc();

View File

@ -18,8 +18,6 @@
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/db/Pmc.h"
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"

View File

@ -10,7 +10,6 @@
#include "td/db/binlog/Binlog.h"
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/ConcurrentBinlog.h"
#include "td/db/KeyValueSyncInterface.h"
#include "td/utils/buffer.h"
@ -175,7 +174,7 @@ class BinlogKeyValue : public KeyValueSyncInterface {
return it->second.first;
}
void force_sync(Promise<> &&promise) {
void force_sync(Promise<> &&promise) override {
binlog_->force_sync(std::move(promise));
}
@ -204,7 +203,7 @@ class BinlogKeyValue : public KeyValueSyncInterface {
return res;
}
void erase_by_prefix(Slice prefix) {
void erase_by_prefix(Slice prefix) override {
auto lock = rw_mutex_.lock_write().move_as_ok();
std::vector<uint64> ids;
for (auto it = map_.begin(); it != map_.end();) {

View File

@ -6,6 +6,8 @@
//
#pragma once
#include "td/actor/PromiseFuture.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
@ -37,6 +39,10 @@ class KeyValueSyncInterface {
virtual std::unordered_map<string, string> get_all() = 0;
virtual SeqNo erase(const string &key) = 0;
virtual void erase_by_prefix(Slice prefix) = 0;
virtual void force_sync(Promise<> &&promise) = 0;
};
} // namespace td

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/db/binlog/BinlogHelper.h"
#include "td/db/binlog/ConcurrentBinlog.h"
#include "td/db/BinlogKeyValue.h"
#include "td/db/SeqKeyValue.h"
#include "td/db/SqliteKeyValue.h"