feat(server): support cluster replication (#2748)

* feat(server): support cluster replication

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-03-26 15:26:19 +02:00 committed by GitHub
parent 3abee8a361
commit 2ad7439128
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 626 additions and 138 deletions

View file

@ -84,9 +84,11 @@ class Service : public facade::ServiceInterface {
// Returns: the new state.
// if from equals the old state then the switch is performed "to" is returned.
// Otherwise, does not switch and returns the current state in the system.
// true if operation is successed
// Upon switch, updates cached global state in threadlocal ServerState struct.
std::pair<GlobalState, bool> SwitchState(GlobalState from, GlobalState to);
GlobalState SwitchState(GlobalState from, GlobalState to);
void RequestLoadingState();
void RemoveLoadingState();
GlobalState GetGlobalState() const;
@ -186,7 +188,8 @@ class Service : public facade::ServiceInterface {
const CommandId* exec_cid_; // command id of EXEC command for pipeline squashing
mutable util::fb2::Mutex mu_;
GlobalState global_state_ = GlobalState::ACTIVE; // protected by mu_;
GlobalState global_state_ ABSL_GUARDED_BY(mu_) = GlobalState::ACTIVE;
uint32_t loading_state_counter_ ABSL_GUARDED_BY(mu_) = 0;
};
uint64_t GetMaxMemoryFlag();