VERSION
VERSION = '3.0.19' : string
版本
Gateway,基于Worker 开发 用于转发客户端的数据给Worker处理,以及转发Worker的数据给客户端
$id : int
Worker id.
$name : string
Name of the worker processes.
$count : int
Number of worker processes.
$user : string
Unix user of processes, needs appropriate privileges (usually root).
$group : string
Unix group of processes, needs appropriate privileges (usually root).
$reloadable : bool
是否可以平滑重启,gateway 不能平滑重启,否则会导致连接断开
$reusePort : bool
reuse port.
$onWorkerStart : callable
Emitted when worker processes start.
$onConnect : callable
Emitted when a socket connection is successfully established.
$onMessage : callable
Emitted when data is received.
$onClose : callable
Emitted when the other end of the socket sends a FIN packet.
$onError : callable
Emitted when an error occurs with connection.
$onBufferFull : callable
Emitted when the send buffer becomes full.
$onBufferDrain : callable
Emitted when the send buffer becomes empty.
$onWorkerStop : callable
Emitted when worker processes stoped.
$onWorkerReload : callable
Emitted when worker processes get reload signal.
$transport : string
Transport layer protocol.
$connections : array
Store all connections of clients.
$protocol : string
Application layer protocol.
$stopping : bool
Is worker stopping ?
$daemonize : bool
Daemonize.
$stdoutFile : string
Stdout file.
$pidFile : string
The file to store master process PID.
$logFile : mixed
Log file.
$globalEvent : \Workerman\Events\EventInterface
Global event loop.
$onMasterReload : callable
Emitted when the master process get reload signal.
$onMasterStop : callable
Emitted when the master process terminated.
$eventLoopClass : string
EventLoopClass
$processTitle : string
Process title
$lanIp : string
本机 IP 单机部署默认 127.0.0.1,如果是分布式部署,需要设置成本机 IP
$lanPort : string
本机端口
$startPort : int
gateway 内部通讯起始端口,每个 gateway 实例应该都不同,步长1000
$registerAddress : string|array
注册服务地址,用于注册 Gateway BusinessWorker,使之能够通讯
$pingInterval : int
心跳时间间隔
$pingNotResponseLimit : int
$pingNotResponseLimit * $pingInterval 时间内,客户端未发送任何数据,断开客户端连接
$pingData : string
服务端向客户端发送的心跳数据
$secretKey : string
秘钥
$router : callable
路由函数
$sendToWorkerBufferSize : int
gateway进程转发给businessWorker进程的发送缓冲区大小
$sendToClientBufferSize : int
gateway进程将数据发给客户端时每个客户端发送缓冲区大小
$protocolAccelerate : bool
协议加速
$onBusinessWorkerConnected : callable|null
BusinessWorker 连接成功之后触发
$onBusinessWorkerClose : callable|null
BusinessWorker 关闭时触发
$_autoloadRootPath : string
Root path for autoload.
$_pauseAccept : bool
Pause accept new connections or not.
$_masterPid : int
The PID of master process.
$_mainSocket : resource
Listening socket.
$_socketName : string
Socket name. The format is like this http://0.0.0.0:80 .
$_localSocket : string
parse from _socketName avoid parse again in master or worker LocalSocket The format is like tcp://0.0.0.0:8080
$_context : resource
Context of socket.
$_workers : \Workerman\Worker[]
All worker instances.
$_pidMap : array
All worker processes pid.
The format is like this [worker_id=>[pid=>pid, pid=>pid, ..], ..]
$_pidsToRestart : array
All worker processes waiting for restart.
The format is like this [pid=>pid, pid=>pid].
$_idMap : array
Mapping from PID to worker process ID.
The format is like this [worker_id=>[0=>$pid, 1=>$pid, ..], ..].
$_status : int
Current status.
$_maxWorkerNameLength : int
Maximum length of the worker names.
$_maxSocketNameLength : int
Maximum length of the socket names.
$_maxUserNameLength : int
Maximum length of the process user names.
$_maxProtoNameLength : int
Maximum length of the Proto names.
$_maxProcessesNameLength : int
Maximum length of the Processes names.
$_maxStatusNameLength : int
Maximum length of the Status names.
$_statisticsFile : string
The file to store status info of current worker process.
$_startFile : string
Start file.
$_OS : string
OS.
$_processForWindows : array
Processes for windows.
$_globalStatistics : array
Status info of current worker process.
$_availableEventLoops : array
Available event loops.
$_builtinTransports : array
PHP built-in protocols.
$_errorType : array
PHP built-in error types.
$_gracefulStop : bool
Graceful stop or not.
$_outputStream : resource
Standard output stream
$_outputDecorated : bool
If $outputStream support decorated
$_clientConnections : array
保存客户端的所有 connection 对象
$_groupConnections : array
group 到 connection 的映射,一对多关系
$_workerConnections : array
保存所有 worker 的内部连接的 connection 对象
$_innerTcpWorker : \Workerman\Worker
gateway 内部监听 worker 内部连接的 worker
$_onWorkerStart : callable
当 worker 启动时
$_onConnect : callable
当有客户端连接时
$_onMessage : callable
当客户端发来消息时
$_onClose : callable
当客户端连接关闭时
$_onWorkerStop : callable
当 worker 停止时
$_startTime : int
进程启动时间
$_gatewayPort : int
gateway 监听的端口
$_connectionIdRecorder : int
connectionId 记录器
routerRand(array $worker_connections, \Workerman\Connection\TcpConnection $client_connection, int $cmd, mixed $buffer) : \Workerman\Connection\TcpConnection
随机路由,返回 worker connection 对象
array | $worker_connections | |
\Workerman\Connection\TcpConnection | $client_connection | |
int | $cmd | |
mixed | $buffer |
routerBind(array $worker_connections, \Workerman\Connection\TcpConnection $client_connection, int $cmd, mixed $buffer) : \Workerman\Connection\TcpConnection
client_id 与 worker 绑定
array | $worker_connections | |
\Workerman\Connection\TcpConnection | $client_connection | |
int | $cmd | |
mixed | $buffer |