148 lines
4.1 KiB
PHP
148 lines
4.1 KiB
PHP
<?php
|
|
|
|
$g_conf_server_switch_cluster = require('../config/serverSwitch.cluster.php');
|
|
$g_conf_accountdb_mysql_cluster = require('../config/accountdb.mysql.cluster.php');
|
|
$g_conf_market_mysql_cluster = require('../config/game2006market.mysql.cluster.php');
|
|
$g_conf_mysql_cluster = require('../config/game2006api.mysql.cluster.php');
|
|
$g_conf_relation_mysql_cluster = require('../config/game2006relation.mysql.cluster.php');
|
|
$g_conf_mail_mysql_cluster = require('../config/mail.mysql.cluster.php');
|
|
$g_conf_log_mysql_cluster = require('../config/logdb.mysql.cluster.php');
|
|
$g_conf_redis_cluster = require('../config/game2006api.redis.cluster.php');
|
|
$g_conf_confdb_mysql_cluster = require('../config/confdb.mysql.cluster.php');
|
|
$g_conf_frienddb_mysql_cluster = require('../config/frienddb.mysql.cluster.php');
|
|
$g_metatables = array();
|
|
|
|
function checkMysqlConfig()
|
|
{
|
|
$instance_id = 1;
|
|
global $g_conf_mysql_cluster;
|
|
foreach ($g_conf_mysql_cluster as $instance) {
|
|
if ($instance_id != $instance['instance_id']) {
|
|
error_log('game2006api.mysql.cluster.php config error');
|
|
die();
|
|
}
|
|
$instance_id++;
|
|
}
|
|
}
|
|
|
|
function checkRedisConfig()
|
|
{
|
|
$instance_id = 1;
|
|
global $g_conf_redis_cluster;
|
|
foreach ($g_conf_redis_cluster as $instance) {
|
|
if ($instance_id != $instance['instance_id']) {
|
|
error_log('game2006api.redis.cluster.php config error');
|
|
die();
|
|
}
|
|
$instance_id++;
|
|
}
|
|
}
|
|
|
|
function getMysqlConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_mysql_cluster;
|
|
$idx = $hash_value % count($g_conf_mysql_cluster);
|
|
return $g_conf_mysql_cluster[$idx];
|
|
}
|
|
|
|
function getAccountDbMysqlConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_accountdb_mysql_cluster;
|
|
return $g_conf_accountdb_mysql_cluster;
|
|
}
|
|
|
|
function getMarketMysqlConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_market_mysql_cluster;
|
|
return $g_conf_market_mysql_cluster;
|
|
}
|
|
|
|
function getRelationMysqlConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_relation_mysql_cluster;
|
|
return $g_conf_relation_mysql_cluster;
|
|
}
|
|
|
|
function getMailMysqlConfig()
|
|
{
|
|
global $g_conf_mail_mysql_cluster;
|
|
return $g_conf_mail_mysql_cluster;
|
|
}
|
|
|
|
function getLogMysqlConfig()
|
|
{
|
|
global $g_conf_log_mysql_cluster;
|
|
return $g_conf_log_mysql_cluster;
|
|
}
|
|
|
|
function getConfDbMysqlConfig()
|
|
{
|
|
global $g_conf_confdb_mysql_cluster;
|
|
return $g_conf_confdb_mysql_cluster;
|
|
}
|
|
|
|
function getFriendDbMysqlConfig()
|
|
{
|
|
global $g_conf_frienddb_mysql_cluster;
|
|
return $g_conf_frienddb_mysql_cluster;
|
|
}
|
|
|
|
function getServerSwitchConfig()
|
|
{
|
|
global $g_conf_server_switch_cluster;
|
|
return $g_conf_server_switch_cluster;
|
|
}
|
|
|
|
function getRedisConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_redis_cluster;
|
|
$idx = $hash_value % count($g_conf_redis_cluster);
|
|
return $g_conf_redis_cluster[$idx];
|
|
}
|
|
|
|
function getMetaTable($tblName)
|
|
{
|
|
global $g_metatables;
|
|
if (!array_key_exists($tblName, $g_metatables)) {
|
|
$g_metatables[$tblName] = require(getResBaseDir() . $tblName);
|
|
}
|
|
return $g_metatables[$tblName];
|
|
}
|
|
|
|
function splitStr1($string)
|
|
{
|
|
return explode('|', $string);
|
|
}
|
|
|
|
function splitStr2($string)
|
|
{
|
|
$result = array();
|
|
foreach (explode('|', $string) as $tmpStr) {
|
|
array_push($result, explode(':', $tmpStr));
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
checkMysqlConfig();
|
|
checkRedisConfig();
|