   'phpDocumentor\Descriptor\FileDescriptor * hash a9a6c7a7948cafaad99240e802322a18 * pathBase/Core.php	 * sourcea<?php
/**
 * 内核基类
 *
 * @author camera360_server@camera360.com
 * @copyright Chengdu pinguo Technology Co.,Ltd.
 */

namespace PG\MSF\Base;

use Exception;
use Noodlehaus\Config;
use PG\MSF\Pack\IPack;
use PG\AOP\Wrapper;
use PG\MSF\Pools\RedisAsynPool;
use PG\MSF\Pools\MysqlAsynPool;
use PG\MSF\Proxy\RedisProxyFactory;
use PG\MSF\Pools\CoroutineRedisProxy;

/**
 * Class Core
 * @package PG\MSF\Base
 */
class Core extends Child
{
    /**
     * @var int 作用计数
     */
    public $__useCount;

    /**
     * @var int 创建时间
     */
    public $__genTime;

    /**
     * @var bool 是否执行构造方法
     */
    public $__isContruct = false;

    /**
     * @var bool 销毁标志
     */
    protected $__isDestroy = false;

    /**
     * @var \stdClass|null 对象模板
     */
    public static $stdClass = null;

    /**
     * @var array redis连接池
     */
    protected $redisPools;

    /**
     * @var array mysql连接池
     */
    protected $mysqlPools;

    /**
     * @var array redis代理池
     */
    protected $redisProxies;

    /**
     * 构造方法
     */
    public function __construct()
    {

    }

    /**
     * 在序列化及dump对象时使用，代表哪些属于需要导出
     *
     * @return array
     */
    public function __sleep()
    {
        return [];
    }

    /**
     * 和__sleep作用相反
     */
    public function __unsleep()
    {
        return [];
    }

    /**
     * 获取运行Server实例
     *
     * @return \swoole_server
     */
    public function getServerInstance()
    {
        return getInstance()->server;
    }

    /**
     * 获取运行server实例配置对象
     *
     * @return Config
     */
    public function getConfig()
    {
        return getInstance()->config;
    }

    /**
     * 获取运行server实例打包对象
     *
     * @return IPack
     */
    public function getPack()
    {
        return getInstance()->pack;
    }

    /**
     * 获取Redis连接池
     *
     * @param string $poolName 配置的Redis连接池名称
     * @return bool|Wrapper|CoroutineRedisProxy|\Redis
     */
    public function getRedisPool(string $poolName)
    {
        $activePoolName = $poolName;
        $poolName       = RedisAsynPool::ASYN_NAME . $poolName;
        if (isset($this->redisPools[$poolName])) {
            return $this->redisPools[$poolName];
        }

        $pool = getInstance()->getAsynPool($poolName);
        if (!$pool) {
            $pool = new RedisAsynPool($this->getConfig(), $activePoolName);
            getInstance()->addAsynPool($poolName, $pool, true);
        }

        $this->redisPools[$poolName] = AOPFactory::getRedisPoolCoroutine($pool->getCoroutine(), $this);
        return $this->redisPools[$poolName];
    }

    /**
     * 获取MySQL连接池
     *
     * @param string $poolName 配置的MySQL连接池名称
     * @return bool|Wrapper
     */
    public function getMysqlPool(string $poolName)
    {
        $activePoolName = $poolName;
        $poolName       = MysqlAsynPool::ASYN_NAME . $poolName;
        if (isset($this->mysqlPools[$poolName])) {
            return $this->mysqlPools[$poolName];
        }

        $pool = getInstance()->getAsynPool($poolName);
        if (!$pool) {
            $pool = new MysqlAsynPool($this->getConfig(), $activePoolName);
            getInstance()->addAsynPool($poolName, $pool, true);
        }

        $this->mysqlPools[$poolName] = AOPFactory::getMysqlPoolCoroutine($pool, $this);
        return $this->mysqlPools[$poolName];
    }

    /**
     * 获取Redis代理
     *
     * @param string $proxyName 配置的Redis代理名称
     * @return bool|Wrapper|CoroutineRedisProxy|\Redis
     * @throws Exception
     */
    public function getRedisProxy(string $proxyName)
    {
        if (isset($this->redisProxies[$proxyName])) {
            return $this->redisProxies[$proxyName];
        }

        $proxy = getInstance()->getRedisProxy($proxyName);
        if (!$proxy) {
            $config = $this->getConfig()->get('redis_proxy.' . $proxyName, null);
            if (!$config) {
                throw new Exception("config redis_proxy.$proxyName not exits");
            }
            $proxy = RedisProxyFactory::makeProxy($proxyName, $config);
            getInstance()->addRedisProxy($proxyName, $proxy);
        }

        $this->redisProxies[$proxyName] = AOPFactory::getRedisProxy($proxy, $this);
        return $this->redisProxies[$proxyName];
    }

    /**
     * 设置RedisPools
     *
     * @param array|null $redisPools 多个Redis连接池实例，通常用于销毁Redis连接池，赋值为NULL
     * @return $this
     */
    public function setRedisPools($redisPools)
    {
        if (!empty($this->redisPools)) {
            foreach ($this->redisPools as $k => &$pool) {
                $pool->destroy();
                $poll = null;
            }
        }

        $this->redisPools = $redisPools;
        return $this;
    }

    /**
     * 设置RedisPools
     *
     * @param array|null $redisProxies 多个Redis代理实例，通常用于销毁Redis代理，赋值为NULL
     * @return $this
     */
    public function setRedisProxies($redisProxies)
    {
        if (!empty($this->redisProxies)) {
            foreach ($this->redisProxies as $k => &$proxy) {
                $proxy->destroy();
                $proxy = null;
            }
        }

        $this->redisProxies = $redisProxies;
        return $this;
    }

    /**
     * 销毁,解除引用
     */
    public function destroy()
    {
        if (!$this->__isDestroy) {
            parent::destroy();
            $this->__isDestroy = true;
        }
    }

    /**
     * 对象已使用标识
     */
    public function isUse()
    {
        $this->__isDestroy = false;
    }

    /**
     * 是否已经执行destroy
     *
     * @return bool
     */
    public function getIsDestroy()
    {
        return $this->__isDestroy;
    }
}
 * namespaceAliases#phpDocumentor\Descriptor\Collection * items	Exception
\ExceptionConfig\Noodlehaus\ConfigIPack\PG\MSF\Pack\IPackWrapper\PG\AOP\WrapperRedisAsynPool\PG\MSF\Pools\RedisAsynPoolMysqlAsynPool\PG\MSF\Pools\MysqlAsynPoolRedisProxyFactory\PG\MSF\Proxy\RedisProxyFactoryCoroutineRedisProxy!\PG\MSF\Pools\CoroutineRedisProxy * includes	  * constants	  * functions	 
 * classes	\PG\MSF\Base\Core(phpDocumentor\Descriptor\ClassDescriptor	 * parent\PG\MSF\Base\Child * implements	  * abstract * final	  * properties	
__useCount+phpDocumentor\Descriptor\PropertyDescriptor " * types 
 * default 	 * static * visibilitypublic * fqsen\PG\MSF\Base\Core::__useCount * name& * namespace 
 * package
 * summary * description * fileDescriptor  * line * tags	var	 *phpDocumentor\Descriptor\Tag\VarDescriptor * variableName(	 /phpDocumentor\Descriptor\Type\IntegerDescriptor /73作用计数	 * errors	 <	  * inheritedElement 	__genTime' "( ) *+,-\PG\MSF\Base\Core::__genTime/>0 1234 5"6	7	 89(	 : /73创建时间<	 <	 = __isContruct' "( )false*+,-\PG\MSF\Base\Core::__isContruct/A0 1234 5'6	7	 89(	 /phpDocumentor\Descriptor\Type\BooleanDescriptor /73是否执行构造方法<	 <	 = __isDestroy' "( )B*+	protected-\PG\MSF\Base\Core::__isDestroy/F0 1234 5,6	7	 89(	 D /73销毁标志<	 <	 = stdClass' "( )null*+,-\PG\MSF\Base\Core::stdClass/J0 1234 516	7	 89(	 3phpDocumentor\Descriptor\Type\UnknownTypeDescriptor/	\stdClassM/K/73对象模板<	 <	 = 
redisPools' "( ) *+G-\PG\MSF\Base\Core::redisPools/P0 1234 566	7	 89(	 M/array/73redis连接池<	 <	 = 
mysqlPools' "( ) *+G-\PG\MSF\Base\Core::mysqlPools/T0 1234 5;6	7	 89(	 M/R/73mysql连接池<	 <	 = redisProxies' "( ) *+G-\PG\MSF\Base\Core::redisProxies/W0 1234 5@6	7	 89(	 M/R/73redis代理池<	 <	 = 
 * methods	__construct)phpDocumentor\Descriptor\MethodDescriptor "#$*+, * arguments	 - \PG\MSF\Base\Core::__construct()/[0 12构造方法34 5E6	return	 param	 <	 = __sleep\ "#$*+,]	 -\PG\MSF\Base\Core::__sleep()/b0 12C在序列化及dump对象时使用，代表哪些属于需要导出34 5O6	`	 -phpDocumentor\Descriptor\Tag\ReturnDescriptor(	 M/R/`3<	 a	 <	 = 	__unsleep\ "#$*+,]	 -\PG\MSF\Base\Core::__unsleep()/f0 12和__sleep作用相反34 5W6	`	 a	 <	 = getServerInstance\ "#$*+,]	 -&\PG\MSF\Base\Core::getServerInstance()/i0 12获取运行Server实例34 5a6	`	 e(	 M/\swoole_server/`3<	 a	 <	 = 	getConfig\ "#$*+,]	 -\PG\MSF\Base\Core::getConfig()/m0 12$获取运行server实例配置对象34 5k6	`	 e(	 M//`3<	 a	 <	 = getPack\ "#$*+,]	 -\PG\MSF\Base\Core::getPack()/p0 12$获取运行server实例打包对象34 5u6	`	 e(	 M//`3<	 a	 <	 = getRedisPool\ "#$*+,]		$poolName+phpDocumentor\Descriptor\ArgumentDescriptor	 * method"(	 .phpDocumentor\Descriptor\Type\StringDescriptor )  * byReference * isVariadic-/t0 123配置的Redis连接池名称4 5 6	 <	 = -!\PG\MSF\Base\Core::getRedisPool()/s0 12获取Redis连接池34 56	a	 ,phpDocumentor\Descriptor\Tag\ParamDescriptor9t("/a3z<	 `	 e(	 D M/M/M/\Redis/`3<	 <	 = getMysqlPool\ "#$*+,]	tuv"(	 w ) xy-/t0 123配置的MySQL连接池名称4 5 6	 <	 = -!\PG\MSF\Base\Core::getMysqlPool()/0 12获取MySQL连接池34 56	a	 }9t("/a3<	 `	 e(	 D M//`3<	 <	 = getRedisProxy\ "#$*+,]	
$proxyNameuv#(	 w ) xy-/0 123配置的Redis代理名称4 5 6	 <	 = -"\PG\MSF\Base\Core::getRedisProxy()/0 12获取Redis代理34 56	a	 }9(#/a3<	 `	 e(	 D M/M/M/~/`3<	 throws	 -phpDocumentor\Descriptor\Tag\ThrowsDescriptor(	 M//3<	 <	 = setRedisPools\ "#$*+,]	$redisPoolsuv#:(	 M/RM/K) xy-/0 123M多个Redis连接池实例，通常用于销毁Redis连接池，赋值为NULL4 5 6	 <	 = -"\PG\MSF\Base\Core::setRedisPools()/0 12设置RedisPools34 56	a	 }9(#>/a3<	 `	 e(	 M/$this/`3<	 <	 = setRedisProxies\ "#$*+,]	$redisProxiesuv#W(	 M/RM/K) xy-/0 123G多个Redis代理实例，通常用于销毁Redis代理，赋值为NULL4 5 6	 <	 = -$\PG\MSF\Base\Core::setRedisProxies()/0 1234 56	a	 }9(#[/a3<	 `	 e(	 M//`3<	 <	 = destroy\ "#$*+,]	 -\PG\MSF\Base\Core::destroy()/0 12销毁,解除引用34 56	`	 a	 <	 = isUse\ "#$*+,]	 -\PG\MSF\Base\Core::isUse()/0 12对象已使用标识34 56	`	 a	 <	 = getIsDestroy\ "#$*+,]	 -!\PG\MSF\Base\Core::getIsDestroy()/0 12是否已经执行destroy34 56	`	 e(	 D /`3<	 a	 <	 =  * usedTraits	 -/Core0\PG\MSF\Base1PG\MSF\Base2
Class Core34" 56	package	 &phpDocumentor\Descriptor\TagDescriptor/3<	 
subpackage	 <	 =  * interfaces	 	 * traits	 
 * markers	 -/Core.php0 1Default2内核基类34 5 6	author	 -phpDocumentor\Descriptor\Tag\AuthorDescriptor/3camera360_server@camera360.com<	 	copyright	 /3"Chengdu pinguo Technology Co.,Ltd.<	 	 /3<	 	 <	 = 