mirror of https://gitee.com/bigwinds/arangodb
Outsourced config_t
This commit is contained in:
parent
d3dfaab906
commit
2c1f9efc3b
|
@ -0,0 +1,89 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_AGENT_CONFIGURATION_H
|
||||
#define ARANGODB_CONSENSUS_AGENT_CONFIGURATION_H
|
||||
|
||||
namespace arangodb {
|
||||
namespace consensus {
|
||||
|
||||
struct config_t {
|
||||
|
||||
id_t id;
|
||||
double min_ping;
|
||||
double maxPing;
|
||||
std::string end_point;
|
||||
std::vector<std::string> end_points;
|
||||
bool notify;
|
||||
bool supervision;
|
||||
bool waitForSync;
|
||||
double supervisionFrequency;
|
||||
|
||||
config_t () :
|
||||
id(0),
|
||||
minPing(0.3f),
|
||||
maxPing(1.0f),
|
||||
endpoint("tcp://localhost:8529"),
|
||||
notify(false),
|
||||
supervision(false),
|
||||
waitForSync(true),
|
||||
supervisionFrequency(5.0) {}
|
||||
|
||||
config_t (uint32_t i, double min_p, double max_p, std::string ep,
|
||||
std::vector<std::string> const& eps, bool n,
|
||||
bool s, bool w, double f) :
|
||||
id(i),
|
||||
minPing(min_p),
|
||||
maxPing(max_p),
|
||||
endpoint(ep),
|
||||
endpoints(eps),
|
||||
notify(n),
|
||||
supervision(s),
|
||||
waitForSync(w),
|
||||
supervisionFrequency(f){}
|
||||
|
||||
inline size_t size() const {return endpoints.size();}
|
||||
|
||||
query_t const toBuilder () const {
|
||||
query_t ret = std::make_shared<arangodb::velocypack::Builder>();
|
||||
ret->openObject();
|
||||
ret->add("endpoints", VPackValue(VPackValueType::Array));
|
||||
for (auto const& i : endpoints)
|
||||
ret->add(VPackValue(i));
|
||||
ret->close();
|
||||
ret->add("endpoint", VPackValue(endpoint));
|
||||
ret->add("id",VPackValue(id));
|
||||
ret->add("minPing",VPackValue(minPing));
|
||||
ret->add("maxPing",VPackValue(maxPing));
|
||||
ret->add("notify peers", VPackValue(notify));
|
||||
ret->add("supervision", VPackValue(supervision));
|
||||
ret->add("supervision frequency", VPackValue(supervisionFrequency));
|
||||
ret->close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue