Constants

MAX_TOKEN

MAX_TOKEN

TOKEN最大值

ASYN_NAME

ASYN_NAME

连接池类型名称

Properties

$config

$config : \Noodlehaus\Config

Type

\Noodlehaus\Config — 配置对象

$dbQueryBuilder

$dbQueryBuilder : \PG\MSF\Pools\Miner

Type

\PG\MSF\Pools\Miner — SQL Builder

$bindPool

$bindPool : array

Type

array — 绑定的连接映射表

$commands

$commands : \SplQueue

Type

\SplQueue — 待执行命令队列

$pool

$pool : \SplQueue

Type

\SplQueue — 连接池

$callBacks

$callBacks : array

Type

array — 回调函数

$workerId

$workerId : integer

Type

integer — worker进程ID

$server

$server : \swoole_server

Type

\swoole_server — swoole_server实例

$swooleServer

$swooleServer : \PG\MSF\MSFServer

Type

\PG\MSF\MSFServer — server运行实例

$token

$token : integer

Type

integer — 回调Token

$waitConnectNum

$waitConnectNum : integer

Type

integer — 待连接数量

$mysqlMaxCount

$mysqlMaxCount : integer

Type

integer — 连接峰值

$active

$active : string

Type

string — 连接池标识

$mysqlClient

$mysqlClient : \PG\MSF\Pools\Miner

Type

\PG\MSF\Pools\Miner — 同步MySQL客户端

Methods

__construct()

__construct(\Noodlehaus\Config  $config, string  $active) 

MysqlAsynPool constructor.

Parameters

\Noodlehaus\Config $config

配置对象

string $active

连接池名称

addTokenCallback()

addTokenCallback(callable  $callback) : integer

注册回调

Parameters

callable $callback

回调函数

Returns

integer

distribute()

distribute(array  $data) : $this

分发消息

Parameters

array $data

待分发数据

Returns

$this

serverInit()

serverInit(\PG\MSF\MSFServer  $swooleServer, \PG\MSF\Pools\AsynPoolManager  $asynManager) : $this

初始化

Parameters

\PG\MSF\MSFServer $swooleServer

Server实例

\PG\MSF\Pools\AsynPoolManager $asynManager

异步连接池管理器

Returns

$this

workerInit()

workerInit(integer  $workerId) : $this

初始化workerId

Parameters

integer $workerId

worker进程ID

Returns

$this

pushToPool()

pushToPool(mixed  $client) : $this

归还连接

Parameters

mixed $client

连接对象

Returns

$this

getDBQueryBuilder()

getDBQueryBuilder(\PG\MSF\Helpers\Context  $context = null) : \PG\MSF\Pools\Miner

获取DB Query Builder

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

Returns

\PG\MSF\Pools\Miner

execute()

execute(array  $data) 

执行MySQL SQL

Parameters

array $data

执行的SQL信息

Throws

\Exception

prepareOne()

prepareOne() 

创建一个Mysql连接

reconnect()

reconnect(\swoole_mysql|null  $client = null) 

重连或者连接

Parameters

\swoole_mysql|null $client

MySQL连接对象

freeBind()

freeBind(\PG\MSF\Helpers\Context  $context, integer  $bindId) 

释放绑定

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

integer $bindId

bind ID

onClose()

onClose(\swoole_mysql  $client) 

断开链接

Parameters

\swoole_mysql $client

MySQL连接对象

getAsynName()

getAsynName() : string

返回唯一的连接池名称

Returns

string

begin()

begin(\PG\MSF\Helpers\Context  $context, mixed  $object, callable  $callback) : string

开启一个事务

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

mixed $object

绑定对象

callable $callback

执行完成后的回调函数

Returns

string

bind()

bind(\PG\MSF\Helpers\Context  $context, mixed  $object) : string

获取绑定值

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

mixed $object

绑定对象

Returns

string

query()

query(\PG\MSF\Helpers\Context  $context, callable  $callback, integer|null  $bindId = null, string|null  $sql = null) 

执行一个sql语句

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

callable $callback

执行完成后的回调函数

integer|null $bindId

绑定ID

string|null $sql

SQL语句

Throws

\Exception

coroutineBegin()

coroutineBegin(\PG\MSF\Helpers\Context  $context, mixed  $object) : \PG\MSF\Pools\MySql

开启一个协程事务

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

mixed $object

绑定对象

Returns

\PG\MSF\Pools\MySql

commit()

commit(\PG\MSF\Helpers\Context  $context, string  $callback, integer  $id) 

提交一个事务

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

string $callback

执行完成后的回调函数

integer $id

绑定ID

coroutineCommit()

coroutineCommit(\PG\MSF\Helpers\Context  $context, integer  $id) : \PG\MSF\Pools\MySql

协程Commit

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

integer $id

绑定ID

Returns

\PG\MSF\Pools\MySql

rollback()

rollback(\PG\MSF\Helpers\Context  $context, callable  $callback, integer  $id) 

回滚

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

callable $callback

执行完成后的回调函数

integer $id

绑定ID

coroutineRollback()

coroutineRollback(\PG\MSF\Helpers\Context  $context, integer  $id) : \PG\MSF\Pools\MySql

协程Rollback

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

integer $id

绑定ID

Returns

\PG\MSF\Pools\MySql