Better interface to create BackupEngine

Summary: I think it looks nicer. In RocksDB we have both styles, but I think that static method is the more common version.

Test Plan: backupable_db_test

Reviewers: ljin, benj, swk

Reviewed By: ljin

CC: leveldb

Differential Revision: https://reviews.facebook.net/D15519
This commit is contained in:
Igor Canadi 2014-01-28 16:01:53 -08:00
parent ec2fa4a690
commit e5ec7384a0
2 changed files with 5 additions and 5 deletions

View File

@ -85,6 +85,9 @@ class BackupEngine {
public:
virtual ~BackupEngine() {}
static BackupEngine* NewBackupEngine(Env* db_env,
const BackupableDBOptions& options);
virtual Status CreateNewBackup(DB* db, bool flush_before_backup = false) = 0;
virtual Status PurgeOldBackups(uint32_t num_backups_to_keep) = 0;
virtual Status DeleteBackup(BackupID backup_id) = 0;
@ -100,9 +103,6 @@ class BackupEngine {
virtual void DeleteBackupsNewerThan(uint64_t sequence_number) = 0;
};
extern BackupEngine* CreateNewBackupEngine(Env* db_env,
const BackupableDBOptions& options);
// Stack your DB with BackupableDB to be able to backup the DB
class BackupableDB : public StackableDB {
public:

View File

@ -188,8 +188,8 @@ class BackupEngineImpl : public BackupEngine {
static const size_t copy_file_buffer_size_ = 5 * 1024 * 1024LL; // 5MB
};
BackupEngine* CreateNewBackupEngine(Env* db_env,
const BackupableDBOptions& options) {
BackupEngine* BackupEngine::NewBackupEngine(
Env* db_env, const BackupableDBOptions& options) {
return new BackupEngineImpl(db_env, options);
}