-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement C++ file to expose backup API
Summary: This differential implements C++ class that allows to safely trigger backup creation and restoration from any place in C++ using GlobalDBSingleton. The real application ofthis class will be exposing C++ backup API to Rust in the very next diff. Test Plan: The same as for the parent differential but instead of directly calling `SQLiteQueryExecutor` call methods of this class. Reviewers: kamil, michal Reviewed By: michal Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D10509
- Loading branch information
1 parent
c07f1ab
commit bec0c0b
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...Modules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "BackupOperationsExecutor.h" | ||
#include "DatabaseManager.h" | ||
#include "GlobalDBSingleton.h" | ||
#include "Logger.h" | ||
#include "WorkerThread.h" | ||
|
||
namespace comm { | ||
void BackupOperationsExecutor::createMainCompaction(std::string backupID) { | ||
taskType job = [backupID]() { | ||
try { | ||
DatabaseManager::getQueryExecutor().createMainCompaction(backupID); | ||
} catch (const std::exception &e) { | ||
// TODO: Inform Rust networking about main | ||
// compaction creation failure | ||
Logger::log( | ||
"Main compaction creation failed. Details: " + std::string(e.what())); | ||
} | ||
}; | ||
GlobalDBSingleton::instance.scheduleOrRunCancellable(job); | ||
} | ||
|
||
void BackupOperationsExecutor::restoreFromMainCompaction( | ||
std::string mainCompactionPath, | ||
std::string mainCompactionEncryptionKey) { | ||
taskType job = [mainCompactionPath, mainCompactionEncryptionKey]() { | ||
try { | ||
DatabaseManager::getQueryExecutor().restoreFromMainCompaction( | ||
mainCompactionPath, mainCompactionEncryptionKey); | ||
} catch (const std::exception &e) { | ||
// TODO: Inform Rust networking about failure | ||
// of restoration from main compaction. | ||
Logger::log( | ||
"Restore from main compaction failed. Details: " + | ||
std::string(e.what())); | ||
} | ||
}; | ||
GlobalDBSingleton::instance.scheduleOrRunCancellable(job); | ||
} | ||
} // namespace comm |
13 changes: 13 additions & 0 deletions
13
...veModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace comm { | ||
class BackupOperationsExecutor { | ||
public: | ||
static void createMainCompaction(std::string backupID); | ||
static void restoreFromMainCompaction( | ||
std::string mainCompactionPath, | ||
std::string mainCompactionEncryptionKey); | ||
}; | ||
} // namespace comm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters