src/Base.php
public function parseDbConfig(array $_config)
    {
        $config = $_config['database'] ?? [];
        foreach ($config['databases'] as $key => $database) {
            if (isset($config['serverInfo'][$database['serverInfo']])) {
                $config['databases'][$key]['maxConns']      = floor(
                    eval('return ' . $config['databases'][$key]['maxConns'] . ';') / CONFIG['server']['swoole']['worker_num']
                );
                $config['databases'][$key]['maxSpareConns'] = floor(
                    eval('return ' . $config['databases'][$key]['maxSpareConns'] . ';') / CONFIG['server']['swoole']['worker_num']
                );
                $config['databases'][$key]['startConns']    = eval('return ' . $config['databases'][$key]['startConns'] . ';');
                $config['databases'][$key]['maxSpareExp']   = eval('return ' . $config['databases'][$key]['maxSpareExp'] . ';');
                foreach ($config['serverInfo'][$database['serverInfo']] as $s_key => $value) {
                    if (isset($config['account'][$value['account']])) {
                        $host = &$config['serverInfo'][$database['serverInfo']][$s_key]['host'];
                        if (is_array($host)) {
                            $host = $host[array_rand($host)];
                        }
                        if (!isset($config['databases'][$s_key])) {
                            $config['databases'][$s_key] = $config['databases'][$key];
                            $config['databases'][$s_key]['serverInfo'] =
                                $config['serverInfo'][$database['serverInfo']][$s_key];
                            $config['databases'][$s_key]['serverInfo']['account'] =
                                $config['account'][$value['account']];
                        }
                        $config['databases'][$s_key . DB_DELIMITER . $key] = $config['databases'][$key];
                        $config['databases'][$s_key . DB_DELIMITER . $key]['serverInfo'] =
                            $config['serverInfo'][$database['serverInfo']][$s_key];
                        $config['databases'][$s_key . DB_DELIMITER . $key]['serverInfo']['account'] =
                            $config['account'][$value['account']];
                    } else {
                        throw new SMProxyException('Config serverInfo->' . $s_key . '->account is not exists!');
                    }
                }
            } else {
                throw new SMProxyException('Config serverInfo key ' . $database['serverInfo'] . 'is not exists!');
            }
            unset($config['databases'][$key]);
        }
        return $config['databases'];
    }
public function parseDbConfig(array $_config)
    {
        $config = $_config['database'] ?? [];
        foreach ($config['databases'] as $key => $database) {
            if (isset($config['serverInfo'][$database['serverInfo']])) {
                $config['databases'][$key]['maxConns']      = floor(
                    eval('return ' . $config['databases'][$key]['maxConns'] . ';') / CONFIG['server']['swoole']['worker_num']
                );
                $config['databases'][$key]['maxSpareConns'] = floor(
                    eval('return ' . $config['databases'][$key]['maxSpareConns'] . ';') / CONFIG['server']['swoole']['worker_num']
                );
                $config['databases'][$key]['startConns']    = eval('return ' . $config['databases'][$key]['startConns'] . ';');
                $config['databases'][$key]['maxSpareExp']   = eval('return ' . $config['databases'][$key]['maxSpareExp'] . ';');
                foreach ($config['serverInfo'][$database['serverInfo']] as $s_key => $value) {
                    if (isset($config['account'][$value['account']])) {
                        $host = &$config['serverInfo'][$database['serverInfo']][$s_key]['host'];
                        if (is_array($host)) {
                            $host = $host[array_rand($host)];
                        }
                        if (!isset($config['databases'][$s_key])) {
                            $config['databases'][$s_key] = $config['databases'][$key];
                            $config['databases'][$s_key]['serverInfo'] =
                                $config['serverInfo'][$database['serverInfo']][$s_key];
                            $config['databases'][$s_key]['serverInfo']['account'] =
                                $config['account'][$value['account']];
                        }
                        $config['databases'][$s_key . DB_DELIMITER . $key] = $config['databases'][$key];
                        $config['databases'][$s_key . DB_DELIMITER . $key]['serverInfo'] =
                            $config['serverInfo'][$database['serverInfo']][$s_key];
                        $config['databases'][$s_key . DB_DELIMITER . $key]['serverInfo']['account'] =
                            $config['account'][$value['account']];
                    } else {
                        throw new SMProxyException('Config serverInfo->' . $s_key . '->account is not exists!');
                    }
                }
            } else {
                throw new SMProxyException('Config serverInfo key ' . $database['serverInfo'] . 'is not exists!');
            }
            unset($config['databases'][$key]);
        }
        return $config['databases'];
    }
格式化配置项.

@param array $_config

@return array

@throws \SMProxy\SMProxyException