Leosac  0.8.0
Open Source Access Control
ReplicationModule.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "core/CoreUtils.hpp"
23 #include "modules/BaseModule.hpp"
24 
25 namespace Leosac
26 {
27 namespace Module
28 {
35 namespace Replication
36 {
41 {
42  public:
43  ReplicationModule(zmqpp::context &ctx, zmqpp::socket *pipe,
44  const boost::property_tree::ptree &cfg, CoreUtilsPtr utils);
45 
46  ReplicationModule(const ReplicationModule &) = delete;
50 
51  virtual void run() override;
52 
53  private:
54  using TimePoint = std::chrono::system_clock::time_point;
55  void process_config();
56 
63  void replicate();
64 
68  void start_sync();
69 
74  bool fetch_local_version(uint64_t &local);
75 
80  bool fetch_remote_version(uint64_t &remote);
81 
85  int delay_;
86 
90  std::string endpoint_;
91 
95  std::string pubkey_;
96 
98 };
99 }
100 }
101 }
Leosac::Module::Replication::ReplicationModule::process_config
void process_config()
Definition: ReplicationModule.cpp:56
Leosac::Module::Replication::ReplicationModule::pubkey_
std::string pubkey_
Master server's public key.
Definition: ReplicationModule.hpp:95
Leosac::Module::Replication::ReplicationModule::start_sync
void start_sync()
Launch the tasks so that the synchronisation may take place.
Definition: ReplicationModule.cpp:129
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::Replication::ReplicationModule::replicate
void replicate()
Start the replication process.
Definition: ReplicationModule.cpp:63
BaseModule.hpp
Leosac::Module::Replication::ReplicationModule::ReplicationModule
ReplicationModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: ReplicationModule.cpp:31
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Replication::ReplicationModule::fetch_local_version
bool fetch_local_version(uint64_t &local)
Fetch the local configuration version by running a task in the main thread.
Definition: ReplicationModule.cpp:92
Leosac::Module::Replication::ReplicationModule::TimePoint
std::chrono::system_clock::time_point TimePoint
Definition: ReplicationModule.hpp:54
Leosac::Module::Replication::ReplicationModule::operator=
ReplicationModule & operator=(const ReplicationModule &)=delete
Leosac::Module::Replication::ReplicationModule::delay_
int delay_
Delay between 2 replications attempt.
Definition: ReplicationModule.hpp:85
Leosac::Module::Replication::ReplicationModule::last_sync_
TimePoint last_sync_
Definition: ReplicationModule.hpp:97
CoreUtils.hpp
Leosac::Module::Replication::ReplicationModule::endpoint_
std::string endpoint_
Target master server.
Definition: ReplicationModule.hpp:90
Leosac::Module::Replication::ReplicationModule::run
virtual void run() override
This is the main loop of the module.
Definition: ReplicationModule.cpp:40
Leosac::Module::Replication::ReplicationModule
Main class for the replication module.
Definition: ReplicationModule.hpp:40
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
Leosac::Module::Replication::ReplicationModule::fetch_remote_version
bool fetch_remote_version(uint64_t &remote)
Fetch the remote configuration version by running a task in a pool, and sending the CONFIG_VERSION me...
Definition: ReplicationModule.cpp:103