获取资源
@return IPoolResource
543862
public function getResource()
    {
        $selectResult = true;
        if($this->getFree() <= 0)
        {
            if($this->getCount() < $this->config->getMaxResources())
            {
                // 没有空闲连接，当前连接数少于最大连接数
                $this->addResource();
            }
            else 
            {
                if(SWOOLE_VERSION < '4.0.3')
                {
                    // 等待其他协程使用完成后释放连接
                    $read = [$this->queue];
                    $write = null;
                    $selectResult = Channel::select($read, $write, $this->config->getWaitTimeout() / 1000);
                }
                else
                {
                    $selectResult = $this->queue->pop($this->config->getWaitTimeout() / 1000);
                }
                if(false === $selectResult)
                {
                    throw new \RuntimeException(sprintf('AsyncPool [%s] getResource timeout', $this->getName()));
                }
            }
        }
        if(true === $selectResult)
        {
            $resource = $this->queue->pop();
        }
        else
        {
            $resource = $selectResult;
        }
        if(!$resource || (!$resource->checkState() && !$resource->open()))
        {
            throw new \RuntimeException(sprintf('AsyncPool [%s] getResource failed', $this->getName()));
        }
        return $resource;
    }
438181
private function parseReq()
    {
        $this->ip = $this->getIp();
        $this->hostname = $this->env->get('HTTP_HOST');
        $this->referrer = $this->env->get('HTTP_REFERER');
        $this->referer = $this->referrer;
        //请求协议
        $protocol = $this->env->get('SERVER_PROTOCOL');
        //设置变量
        if ($protocol) {
            list($this->protocol, $this->version) = explode('/', $protocol);
            if ($this->protocol == 'https') {
                $this->secure = true;
            } else {
                $this->secure = false;
            }
        } else {
            $this->secure = false;
        }

        return $this;
    }
87208
public static IPool getPool(String host, Integer port, String database, String... userPwd) {
        //暂未启用
        throw new RuntimeException("未找到指定的数据库连接池");
    }
168239
protected function getListResource()
    {
        $items = $this->getListItems();
        $count = $items->count();
        /** @var string $treeClass */
        $treeClass = $this->config()->get('tree_class');
        $hal = [
            'count' => $count,
            'total' => $count,
            '_links' => [
                'self' => [
                    'href' => $this->Link('items')
                ]
            ],
            '_embedded' => [$treeClass => []]
        ];
        /** @var ChangeSet $item */
        foreach ($items as $item) {
            $sync = $this->shouldCampaignSync($item);
            $resource = $this->getChangeSetResource($item, $sync);
            $hal['_embedded'][$treeClass][] = $resource;
        }
        return $hal;
    }
1316299
public function getStorage()
    {
        if (!isset($this->storage)) {
            // 检测配置
            $storageType = StringHelper::toClassName($this->options['storage']);
            $storageClass = '\\Wslim\\Common\\Storage\\'. $storageType . 'Storage';
            if (!class_exists($storageClass)) {
                throw new InvalidArgumentException('storage = null|file|memcache|memcached|redis|xcache ,');
            }
            
            // 实例化 storage
            $partialOptions = [];
            foreach($this->options as $k => $v) {
                if (in_array($k, StorageInterface::AllowOptions)) {
                    $partialOptions[$k] = $v;
                    //unset($this->options[$k]);
                }
            }
            
            $this->storage = new $storageClass($partialOptions);
        }
        
        return $this->storage;
    }
321
private static function pushResourceToRequestContext(IPoolResource $resource)
    {
        $poolResources = RequestContext::get('poolResources', []);
        $instance = $resource->getInstance();
        $poolResources[spl_object_hash($instance)] = $resource;
        RequestContext::set('poolResources', $poolResources);
    }
76991
public function release(IPoolResource $resource)
    {
        $hash = $resource->hashCode();
        if(isset($this->pool[$hash]))
        {
            $this->pool[$hash]->release();
            $resource->reset();
            $this->push($resource);
        }
    }
1357396
protected function hostIpinfo()
    {
        $ipinfo = $this->ipinfo->getYourOwnIpDetails()->getProperties();
        $this->results['host'] = $ipinfo;

        return $this;
    }
388963
public function getCurrentResources()
    {
        // Getting the current Source element
        $source = $this->getCurrentSource();

        // Getting the data
        if ($source instanceof SourceInterface) {
            // Getting result iterator
            return $this->getResources($source);
        }
        return null;
    }
917383
public function toResource()
    {
        $protocol = $this->collection->database->connection->registerFileStreamWrapper();

        $context = stream_context_create([
            $protocol => [
                'download' => $this,
            ]
        ]);

        $document = $this->getDocument();
        $url = "{$protocol}://{$this->collection->database->name}.{$this->collection->prefix}?_id={$document['_id']}";
        return fopen($url, 'r', false, $context);
    }
1123864
public function getResource():ResourceInterface
    {
        $this->manager->parseIncludes($this->relations);
        $transformer = $this->resource->getTransformer();

        if ($transformer instanceof Transformer && $transformer->allRelationsAllowed()) {
            $this->resource->setTransformer($transformer->setRelations($this->manager->getRequestedIncludes()));
        }

        return $this->resource->setMeta($this->meta);
    }
42864
private function buildGetSource() {
        $method = new Object\Method();
        $method->setAccess('public');
        $method->setDescription('This returns the table name');
        $method->setName('getSource');
        $method->setReturnType('string');
        $method->setContent('return \'' . $this->getTableName() . '\';');
        $this->getAbstractClass()->addMethod($method);
    }
907041
public Jedis getResource(int DBIndex) {
        try {
            if (this.jedisPool == null)
                throw new NullPointerException(this.name + ", Jedis Pool 未初始化");

            Jedis jedis = this.jedisPool.getResource();

            jedis.select(DBIndex);

            return jedis;
        } catch (JedisConnectionException e) {
            LOG.error(this.name + ", Jedis Pool 连接出现异常", e);
            throw e;
        } catch (JedisException e) {
            LOG.error(this.name + ", Jedis Pool 出现异常", e);
            throw e;
        } catch (Exception e) {
            LOG.error(this.name + ", Jedis Pool 获取连接, 暂时无法识别异常", e);
            throw e;
        }
    }
135967
protected function getFileResource()
    {
        if (null === $this->fileResource) {
            $fileResource = @fopen($this->getFileName(), 'a+');
            if (! $fileResource) {
                throw new RuntimeException('Could not open pidfile');
            }
            $this->fileResource = $fileResource;
        }

        return $this->fileResource;
    }
885285
public function start()
    {
        if (!$this->httpEnable) {
            parent::start();
            return $this;
        }

        if (static::mode == 'console') {
            $this->beforeSwooleStart();
            $this->onWorkerStart(null, null);
        } else {
            //开启一个http服务器
            $mode = $this->config->get('server.mode', SWOOLE_PROCESS);
            $this->server = new \swoole_http_server($this->httpSocketName, $this->httpPort, $mode);
            $this->server->on('Start', [$this, 'onStart']);
            $this->server->on('WorkerStart', [$this, 'onWorkerStart']);
            $this->server->on('WorkerStop', [$this, 'onWorkerStop']);
            $this->server->on('Task', [$this, 'onTask']);
            $this->server->on('Finish', [$this, 'onFinish']);
            $this->server->on('PipeMessage', [$this, 'onPipeMessage']);
            $this->server->on('WorkerError', [$this, 'onWorkerError']);
            $this->server->on('ManagerStart', [$this, 'onManagerStart']);
            $this->server->on('ManagerStop', [$this, 'onManagerStop']);
            $this->server->on('request', [$this, 'onRequest']);
            $this->server->on('Shutdown', [$this, 'onShutdown']);
            $set = $this->setServerSet();
            $set['daemonize'] = self::$daemonize ? 1 : 0;
            $this->server->set($set);
            $this->beforeSwooleStart();
            $this->server->start();
        }

        return $this;
    }
1112098
public function resource()
    {
        if (!is_resource($this->value)) {
            throw new InvalidResourceException($this->name, $this->value);
        }

        return $this;
    }
277495
public function getPdo()
    {
        // 分析查询表达式
        $options = $this->parseExpress();
        // 生成查询SQL
        $sql = $this->builder->select($options);
        // 获取参数绑定
        $bind = $this->getBind();
        if ($options['fetch_sql']) {
            // 获取实际执行的SQL语句
            return $this->connection->getRealSql($sql, $bind);
        }
        // 执行查询操作
        return $this->query($sql, $bind, $options['master'], true);
    }