62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
#include "precompile.h"
|
|
|
|
#include "jsondatamgr.h"
|
|
#include "app.h"
|
|
|
|
#include "framework/cpp/utils.h"
|
|
|
|
void JsonDataMgr::Init()
|
|
{
|
|
if (!f8::IsOnlineEnv()) {
|
|
if (f8::IsTestEnv()) {
|
|
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/rankserver.test",
|
|
{
|
|
GAME_ID,
|
|
App::Instance()->instance_id,
|
|
GAME_ID
|
|
});
|
|
} else {
|
|
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/rankserver.dev",
|
|
{
|
|
GAME_ID,
|
|
App::Instance()->instance_id,
|
|
GAME_ID
|
|
});
|
|
}
|
|
}
|
|
std::string rankserver_cluster_json_file;
|
|
std::string mysql_cluster_json_file;
|
|
mysql_cluster_json_file = a8::Format("%s/node1/friend.rankserver.mysql.cluster.json",
|
|
{
|
|
work_path_,
|
|
});
|
|
|
|
rankserver_cluster_json_file = a8::Format("%s/node1/game9003.rankserver.cluster.json",
|
|
{
|
|
work_path_,
|
|
});
|
|
rankserver_cluster_json_.ReadFromFile(rankserver_cluster_json_file);
|
|
}
|
|
|
|
void JsonDataMgr::UnInit()
|
|
{
|
|
}
|
|
|
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
|
|
{
|
|
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > rankserver_cluster_json_.Size()) {
|
|
abort();
|
|
}
|
|
return rankserver_cluster_json_[App::Instance()->instance_id - 1];
|
|
}
|
|
|
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetMysqlClusterConf()
|
|
{
|
|
return std::make_shared<a8::XObject>(mysql_cluster_json_);
|
|
}
|
|
|
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetMysqlConf(int instance_id)
|
|
{
|
|
return mysql_cluster_json_[instance_id - 1];
|
|
}
|