\PG\MSF\CoroutineHttp

Class Http

Summary

Methods
Properties
Constants
__construct()
getResult()
throwTimeOutException()
isTimeout()
nextRun()
destroy()
__unsleep()
breakx()
setTimeout()
send()
$maxTimeout
$request
$result
$timeout
$requestTime
$responseTime
$ioBack
$ioBackKey
$isBreak
$requestId
$client
$data
$path
$method
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$maxTimeout

$maxTimeout : integer

Type

integer — 协程运行的最大超时时间

$request

$request : string

Type

string — 请求参数

$result

$result : mixed

Type

mixed — IO协程运行的结束

$timeout

$timeout : integer

Type

integer — 协程执行的超时时间精确到ms

$requestTime

$requestTime : float

Type

float — 协程执行请求开始时间

$responseTime

$responseTime : float

Type

float — 协程执行请求结束时间

$ioBack

$ioBack : boolean

Type

boolean — IO协程是否返回数据

$ioBackKey

$ioBackKey : integer|null

Type

integer|null — ioBack标识

$isBreak

$isBreak : boolean

Type

boolean — 是否发送异步请求后不需要执行回调

$requestId

$requestId : string|null

Type

string|null — 整个请求标识

$data

$data : string|array

Type

string|array — 发送的数据

$path

$path : string

Type

string — 请求的URL PATH

$method

$method : string

Type

string — 请求的方法

Methods

__construct()

__construct(\PG\MSF\Client\Http\Client  $client, string  $method, string  $path, string|array  $data, integer  $timeout) 

初始化Http异步请求协程对象

Parameters

\PG\MSF\Client\Http\Client $client

Client实例

string $method

HTTP请求的方法

string $path

HTTP请求的URL Path

string|array $data

发送的数据

integer $timeout

超时时间,单位毫秒

getResult()

getResult() : mixed|null

获取协程执行结果

Returns

mixed|null

throwTimeOutException()

throwTimeOutException() 

协程超时异常

Throws

\Exception

isTimeout()

isTimeout() : boolean

判断协程是否超时

Returns

boolean

nextRun()

nextRun() : boolean

通知调度器进行下一次迭代

Returns

boolean

destroy()

destroy() 

销毁

__unsleep()

__unsleep() : array

属性不用于序列化

Returns

array

breakx()

breakx() : boolean

发送异步请求后不需要执行回调

Returns

boolean

setTimeout()

setTimeout(integer  $timeout) : $this

手工设置超时时间

Parameters

integer $timeout

超时时间,单位毫秒

Returns

$this

send()

send(callable  $callback) 

发送异步的HTTP请求

Parameters

callable $callback

请求响应的回调函数