Leosac  0.7.0
OpenSourceAccessControl
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 }
bool fetch_local_version(uint64_t &local)
Fetch the local configuration version by running a task in the main thread.
int delay_
Delay between 2 replications attempt.
This is the header file for a generated source file, GitSHA1.cpp.
ReplicationModule & operator=(const ReplicationModule &)=delete
std::chrono::system_clock::time_point TimePoint
std::string endpoint_
Target master server.
virtual void run() override
This is the main loop of the module.
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...
std::string pubkey_
Master server&#39;s public key.
void start_sync()
Launch the tasks so that the synchronisation may take place.
Base class for module implementation.
Definition: BaseModule.hpp:110
void replicate()
Start the replication process.
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
ReplicationModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Main class for the replication module.