Properties

$__useCount

$__useCount : integer

Type

integer — 作用计数

$__genTime

$__genTime : integer

Type

integer — 创建时间

$__isContruct

$__isContruct : boolean

Type

boolean — 是否执行构造方法

$stdClass

$stdClass : \stdClass|null

Type

\stdClass|null — 对象模板

$version

$version : string

Type

string — 当前版本

$service

$service : string

Type

string — 服务名称

$host

$host : string

Type

string — host地址,支持 http/https 协议,支持域名地址,支持带端口. http://127.0.0.1 | http://hostname | http://127.0.0.1:80 | http://hostname:80 https://127.0.0.1 | https://hostname | https://127.0.0.1:443 | https://hostname:443

$timeout

$timeout : integer

Type

integer — 超时时间(单位毫秒)

$scheme

$scheme : string

Type

string — 使用协议,http

$urlPath

$urlPath : string

Type

string — url path,如 /path,当不使用rpc模式时,应设置本参数;

$verb

$verb : string

Type

string — 动作,如GET/POST

$handler

$handler : string

Type

string — handler名称

$construct

$construct : string

Type

string — handler的构造参数

$method

$method : string

Type

string — handler的方法名

$args

$args : array

Type

array — handler的方法参数

$__isDestroy

$__isDestroy : boolean

Type

boolean — 销毁标志

$redisPools

$redisPools : array

Type

array — redis连接池

$mysqlPools

$mysqlPools : array

Type

array — mysql连接池

$redisProxies

$redisProxies : array

Type

array — redis代理池

$reflections

$reflections : array

Type

array — 反射类属性的默认值

$services

$services : array

Type

array — 所有服务

Methods

__construct()

__construct(string  $service) 

RpcClient constructor.

Parameters

string $service

服务名称,如 'user'

Throws

\Exception

__sleep()

__sleep() : array

在序列化及dump对象时使用,代表哪些属于需要导出

Returns

array

__unsleep()

__unsleep() 

和__sleep作用相反

getServerInstance()

getServerInstance() : \swoole_server

获取运行Server实例

Returns

\swoole_server

getConfig()

getConfig() : \Noodlehaus\Config

获取运行server实例配置对象

Returns

\Noodlehaus\Config

getPack()

getPack() : \PG\MSF\Pack\IPack

获取运行server实例打包对象

Returns

\PG\MSF\Pack\IPack

getRedisPool()

getRedisPool(string  $poolName) : boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

获取Redis连接池

Parameters

string $poolName

配置的Redis连接池名称

Returns

boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

getMysqlPool()

getMysqlPool(string  $poolName) : boolean|\PG\AOP\Wrapper

获取MySQL连接池

Parameters

string $poolName

配置的MySQL连接池名称

Returns

boolean|\PG\AOP\Wrapper

getRedisProxy()

getRedisProxy(string  $proxyName) : boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

获取Redis代理

Parameters

string $proxyName

配置的Redis代理名称

Throws

\Exception

Returns

boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

setRedisPools()

setRedisPools(array|null  $redisPools) : $this

设置RedisPools

Parameters

array|null $redisPools

多个Redis连接池实例,通常用于销毁Redis连接池,赋值为NULL

Returns

$this

setRedisProxies()

setRedisProxies(array|null  $redisProxies) : $this

设置RedisPools

Parameters

array|null $redisProxies

多个Redis代理实例,通常用于销毁Redis代理,赋值为NULL

Returns

$this

destroy()

destroy() 

销毁,解除引用

isUse()

isUse() 

对象已使用标识

getIsDestroy()

getIsDestroy() : boolean

是否已经执行destroy

Returns

boolean

setContext()

setContext(\PG\MSF\Helpers\Context  $context) : $this

设置上下文

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

Returns

$this

handler()

handler(string  $handler,   $construct = null) : \PG\MSF\Client\RpcClient

指定服务句柄,一般为RPC服务导出的类名

Parameters

string $handler

服务句柄(类名)

$construct

Returns

\PG\MSF\Client\RpcClient

func()

func(string  $method, array  $args) : $this

拼装handler执行的方法和参数

Parameters

string $method

handler执行的方法

array $args

handler执行的参数

Returns

$this

__call()

__call(string  $method, mixed  $args) : mixed

指定一个远程服务句柄的方法

Parameters

string $method

方法名

mixed $args

执行的参数列表

Throws

\Exception

Returns

mixed

remoteHttpCall()

remoteHttpCall(string  $method, array  $args) : mixed

Rpc模式执行远程调用

Parameters

string $method

远程服务句柄的方法名

array $args

执行的参数列表

Throws

\Exception

Returns

mixed

goConcurrent()

goConcurrent(array  $multiRpc) : array

多个RPC并行请求

Parameters

array $multiRpc

RpcClient实例列表

Returns

array