PHP Class Bootstrap\Worker

Afficher le fichier Open project: smalleyes/statistics Class Usage Examples

Méthodes publiques

Свойство Type Description
$instance

Protected Properties

Свойство Type Description
$_maxManagerPidLength
$_maxMasterPidLength integer MasterPid命令时格式化输出 ManagerPid命令时格式化输出 WorkerId命令时格式化输出 WorkerPid命令时格式化输出
$_maxWorkerIdLength
$_maxWorkerPidLength
$handleProviderPort
$handleWorkerPort
$logBuffer string 日志的buffer
$logDir string 存放统计日志的目录
$masterPidPath string master pid path
$statisticData array 统计数据 ip=>modid=>interface=>['code'=>[xx=>count,xx=>count],'suc_cost_time'=>xx,'fail_cost_time'=>xx, 'suc_count'=>xx, 'fail_count'=>xx]
$statisticDir string 存放统计数据的目录
$udpFinderport

Méthodes publiques

Méthode Description
__construct ( )
clearDisk ( string $file = null, integer $exp_time = 86400 ) 清除磁盘数据
decode ( unknown $buffer ) : mixed 解包
getRedis ( ) : unknown 返回redis链接资源
log ( unknown $msg ) 日志
onClose ( unknown $serv, unknown $fd, unknown $from_id ) 链接断开
onConnect ( swoole_server $serv, unknown $fd, unknown $from_id ) 建立链接
onFinish ( swoole_server $serv, unknown $task_id, unknown $data ) task执行完毕调用
onReceive ( swoole_server $serv, unknown $fd, unknown $from_id, unknown $data ) 接收数据
onShutdown ( unknown $serv ) 关闭服务器
onStart ( swoole_server $serv ) swoole_start 回调函数
onTask ( swoole_server $serv, unknown $task_id, unknown $from_id, unknown $data ) : void | multitype:string task任务
onWorkerError ( swoole_server $serv, unknown $worker_id, unknown $worker_pid, unknown $exit_code ) worker出现问题调用
onWorkerStart ( unknown $serv, unknown $worker_id ) 进程启动
onWorkerStop ( unknown $serv, unknown $worker_id ) 关闭进程
processRename ( unknown $serv, unknown $worker_id ) 修改进程名
run ( $ip = "0.0.0.0", $port = 55656, $mode = SWOOLE_PROCESS, $type = SWOOLE_SOCK_TCP )
writeLogToDisk ( ) : void 将日志数据写入磁盘
writeStatisticsToDisk ( ) : void 将统计数据写入磁盘

Méthodes protégées

Méthode Description
collectStatistics ( string $module, string $interface, float $cost_time, integer $success, string $ip, integer $code, string $msg ) : void 收集统计数据

Method Details

__construct() public méthode

public __construct ( )

clearDisk() public méthode

清除磁盘数据
public clearDisk ( string $file = null, integer $exp_time = 86400 )
$file string
$exp_time integer

collectStatistics() protected méthode

收集统计数据
protected collectStatistics ( string $module, string $interface, float $cost_time, integer $success, string $ip, integer $code, string $msg ) : void
$module string
$interface string
$cost_time float
$success integer
$ip string
$code integer
$msg string
Résultat void

decode() public static méthode

解包
public static decode ( unknown $buffer ) : mixed
$buffer unknown
Résultat mixed

getRedis() public méthode

返回redis链接资源
public getRedis ( ) : unknown
Résultat unknown

log() public méthode

日志
public log ( unknown $msg )
$msg unknown

onClose() public méthode

链接断开
public onClose ( unknown $serv, unknown $fd, unknown $from_id )
$serv unknown
$fd unknown
$from_id unknown

onConnect() public méthode

建立链接
public onConnect ( swoole_server $serv, unknown $fd, unknown $from_id )
$serv swoole_server
$fd unknown
$from_id unknown

onFinish() public méthode

task执行完毕调用
public onFinish ( swoole_server $serv, unknown $task_id, unknown $data )
$serv swoole_server
$task_id unknown
$data unknown

onReceive() public méthode

接收数据
public onReceive ( swoole_server $serv, unknown $fd, unknown $from_id, unknown $data )
$serv swoole_server
$fd unknown
$from_id unknown
$data unknown

onShutdown() public méthode

关闭服务器
public onShutdown ( unknown $serv )
$serv unknown

onStart() public méthode

swoole_start 回调函数
public onStart ( swoole_server $serv )
$serv swoole_server

onTask() public méthode

task任务
public onTask ( swoole_server $serv, unknown $task_id, unknown $from_id, unknown $data ) : void | multitype:string
$serv swoole_server
$task_id unknown
$from_id unknown
$data unknown
Résultat void | multitype:string

onWorkerError() public méthode

worker出现问题调用
public onWorkerError ( swoole_server $serv, unknown $worker_id, unknown $worker_pid, unknown $exit_code )
$serv swoole_server
$worker_id unknown
$worker_pid unknown
$exit_code unknown

onWorkerStart() public méthode

进程启动
public onWorkerStart ( unknown $serv, unknown $worker_id )
$serv unknown
$worker_id unknown

onWorkerStop() public méthode

关闭进程
public onWorkerStop ( unknown $serv, unknown $worker_id )
$serv unknown
$worker_id unknown

processRename() public méthode

修改进程名
public processRename ( unknown $serv, unknown $worker_id )
$serv unknown
$worker_id unknown

run() public méthode

public run ( $ip = "0.0.0.0", $port = 55656, $mode = SWOOLE_PROCESS, $type = SWOOLE_SOCK_TCP )

writeLogToDisk() public méthode

将日志数据写入磁盘
public writeLogToDisk ( ) : void
Résultat void

writeStatisticsToDisk() public méthode

将统计数据写入磁盘
public writeStatisticsToDisk ( ) : void
Résultat void

Property Details

$_maxManagerPidLength protected_oe static_oe property

protected static $_maxManagerPidLength

$_maxMasterPidLength protected_oe static_oe property

MasterPid命令时格式化输出 ManagerPid命令时格式化输出 WorkerId命令时格式化输出 WorkerPid命令时格式化输出
protected static int $_maxMasterPidLength
Résultat integer

$_maxWorkerIdLength protected_oe static_oe property

protected static $_maxWorkerIdLength

$_maxWorkerPidLength protected_oe static_oe property

protected static $_maxWorkerPidLength

$handleProviderPort protected_oe property

protected $handleProviderPort

$handleWorkerPort protected_oe property

protected $handleWorkerPort

$instance public_oe static_oe property

public static $instance

$logBuffer protected_oe property

日志的buffer
protected string $logBuffer
Résultat string

$logDir protected_oe property

存放统计日志的目录
protected string $logDir
Résultat string

$masterPidPath protected_oe property

master pid path
protected string $masterPidPath
Résultat string

$statisticData protected_oe property

统计数据 ip=>modid=>interface=>['code'=>[xx=>count,xx=>count],'suc_cost_time'=>xx,'fail_cost_time'=>xx, 'suc_count'=>xx, 'fail_count'=>xx]
protected array $statisticData
Résultat array

$statisticDir protected_oe property

存放统计数据的目录
protected string $statisticDir
Résultat string

$udpFinderport protected_oe property

protected $udpFinderport