PHP Class Swoole\Client\RPC

Datei anzeigen Open project: matyhtf/swoole_framework Class Usage Examples

Protected Properties

Property Type Description
$_instances
$encode_gzip
$encode_json
$env
$haveSockets
$haveSwoole
$keepConnection boolean 启用长连接
$packet_maxlen
$password
$requestIndex
$servers array Server的实例列表
$timeout
$user
$waitList

Public Methods

Method Description
__construct ( $id = null )
addServers ( array $servers ) 添加服务器
auth ( $user, $password ) 设置用户名和密码
getEnv ( ) : array 设置环境变量
getInstance ( $id = null ) : RPC 获取SOA服务实例
getRequestId ( ) : integer 生成请求串号
getServer ( ) : array 从配置中取出一个服务器配置
onConnectServerFailed ( $svr ) : boolean 连接服务器失败了
ping ( ) 侦测服务器是否存活
putEnv ( $k, $v ) 设置一项环境变量
setEncodeType ( $json, $gzip ) 设置编码类型
setEnv ( array $env ) 获取环境变量
setServers ( array $servers ) 设置服务器
setTimeout ( $timeout ) 设置超时时间,包括连接超时和接收超时
task ( $function, $params = [], $callback = null ) : SOA_Result RPC调用
wait ( float $timeout = 0.5 ) : integer 并发请求

Protected Methods

Method Description
afterRequest ( $retObj )
beforeRequest ( $retObj )
connectToServer ( SOA_Result $retObj ) : boolean 连接到服务器
finish ( $retData, $retObj ) 完成请求
formatServerConfig ( &$config )
recvWaitWithSockets ( $timeout ) : integer 使用sockets扩展
recvWaitWithSwoole ( $timeout ) : integer 使用Swoole扩展
request ( $send, SOA_result $retObj ) : boolean 发送请求

Method Details

__construct() public method

public __construct ( $id = null )

addServers() public method

添加服务器
public addServers ( array $servers )
$servers array

afterRequest() protected method

protected afterRequest ( $retObj )

auth() public method

设置用户名和密码
public auth ( $user, $password )
$user
$password

beforeRequest() protected method

protected beforeRequest ( $retObj )

connectToServer() protected method

连接到服务器
protected connectToServer ( SOA_Result $retObj ) : boolean
$retObj SOA_Result
return boolean

finish() protected method

完成请求
protected finish ( $retData, $retObj )
$retData
$retObj

formatServerConfig() protected static method

protected static formatServerConfig ( &$config )
$config

getEnv() public method

设置环境变量
public getEnv ( ) : array
return array

getInstance() static public method

获取SOA服务实例
static public getInstance ( $id = null ) : RPC
$id
return RPC

getRequestId() static public method

生成请求串号
static public getRequestId ( ) : integer
return integer

getServer() public method

从配置中取出一个服务器配置
public getServer ( ) : array
return array

onConnectServerFailed() public method

连接服务器失败了
public onConnectServerFailed ( $svr ) : boolean
$svr
return boolean

ping() public method

侦测服务器是否存活
public ping ( )

putEnv() public method

设置一项环境变量
public putEnv ( $k, $v )
$k
$v

recvWaitWithSockets() protected method

使用sockets扩展
protected recvWaitWithSockets ( $timeout ) : integer
$timeout
return integer

recvWaitWithSwoole() protected method

使用Swoole扩展
protected recvWaitWithSwoole ( $timeout ) : integer
$timeout
return integer

request() protected method

发送请求
protected request ( $send, SOA_result $retObj ) : boolean
$send
$retObj SOA_result
return boolean

setEncodeType() public method

设置编码类型
public setEncodeType ( $json, $gzip )
$json
$gzip

setEnv() public method

获取环境变量
public setEnv ( array $env )
$env array

setServers() public method

设置服务器
public setServers ( array $servers )
$servers array

setTimeout() public method

设置超时时间,包括连接超时和接收超时
public setTimeout ( $timeout )
$timeout

task() public method

RPC调用
public task ( $function, $params = [], $callback = null ) : SOA_Result
$function
$params
$callback
return SOA_Result

wait() public method

并发请求
public wait ( float $timeout = 0.5 ) : integer
$timeout float
return integer

Property Details

$_instances protected_oe static_oe property

protected static $_instances

$encode_gzip protected_oe property

protected $encode_gzip

$encode_json protected_oe property

protected $encode_json

$env protected_oe property

protected $env

$haveSockets protected_oe property

protected $haveSockets

$haveSwoole protected_oe property

protected $haveSwoole

$keepConnection protected_oe property

启用长连接
protected bool $keepConnection
return boolean

$packet_maxlen protected_oe property

protected $packet_maxlen

$password protected_oe property

protected $password

$requestIndex protected_oe property

protected $requestIndex

$servers protected_oe property

Server的实例列表
protected array $servers
return array

$timeout protected_oe property

protected $timeout

$user protected_oe property

protected $user

$waitList protected_oe property

protected $waitList