Skip to content

Commit

Permalink
Merge pull request #1 from sy-records/master
Browse files Browse the repository at this point in the history
Update SwooleTracker
  • Loading branch information
Yurunsoft authored Aug 30, 2019
2 parents a1c1d26 + cbadfee commit d63f695
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
/composer.lock
.runtime
.idea
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ Swoole Tracker: https://www.swoole-cloud.com/tracker.html

* 所有工具零部署成本,后台一键开启关闭各种检测,完美支持PHP7。

## Composer
## Swoole Tracker

本项目可以使用composer安装,遵循psr-4自动加载规则,在你的 `composer.json` 中加入下面的内容:
目前`Swoole Tracker``v2.5.0`版本支持自动生成应用名称并创建应用,无需修改任何代码,生成的应用名称格式为:

`Swoole``HttpServer``ip:prot`

其他的`Server``ip(hostname):prot`

即安装好`swoole_tracker`扩展之后就可以正常使用`Swoole Tracker`的功能

## 组件基本使用

1. 在你的 `composer.json` 中加入下面的内容:

```json
{
Expand All @@ -33,11 +43,9 @@ Swoole Tracker: https://www.swoole-cloud.com/tracker.html
}
```

然后执行 `composer update` 安装。

## 基本使用
2. 执行 `composer update` 安装。

在项目 `config/config.php` 中配置:
3. 在项目 `config/config.php` 中配置:

```php
[
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/SwooleTrackerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SwooleTrackerMiddleware extends BaseMiddleware implements MiddlewareInterf

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$tick = \StatsCenter::beforeExecRpc($request->getUri()->getPath(), $this->serviceName, $this->serverIp);
$tick = \SwooleTracker\Stats::beforeExecRpc($request->getUri()->getPath(), $this->serviceName, $this->serverIp);
try {
$success = $code = null;
$response = $handler->handle($request);
Expand Down Expand Up @@ -52,7 +52,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
{
$code = $success ? $this->successCode : $response->getStatusCode();
}
\StatsCenter::afterExecRpc($tick, $success, $code);
\SwooleTracker\Stats::afterExecRpc($tick, $success, $code);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/TCP/Middleware/SwooleTrackerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __init()
public function process(IReceiveData $data, IReceiveHandler $handler)
{
$funcName = ($this->nameHandler)($data);
$tick = \StatsCenter::beforeExecRpc($funcName, $this->serviceName, $this->serverIp);
$tick = \SwooleTracker\Stats::beforeExecRpc($funcName, $this->serviceName, $this->serverIp);
try {
$success = $code = null;
$result = $handler->handle($data);
Expand Down Expand Up @@ -61,7 +61,7 @@ public function process(IReceiveData $data, IReceiveHandler $handler)
{
$code = $success ? $this->successCode : $this->exceptionCode;
}
\StatsCenter::afterExecRpc($tick, $success, $code);
\SwooleTracker\Stats::afterExecRpc($tick, $success, $code);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/UDP/Middleware/SwooleTrackerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __init()
public function process(IPacketData $data, IPacketHandler $handler)
{
$funcName = ($this->nameHandler)($data);
$tick = \StatsCenter::beforeExecRpc($funcName, $this->serviceName, $this->serverIp);
$tick = \SwooleTracker\Stats::beforeExecRpc($funcName, $this->serviceName, $this->serverIp);
try {
$success = $code = null;
$result = $handler->handle($data);
Expand Down Expand Up @@ -61,7 +61,7 @@ public function process(IPacketData $data, IPacketHandler $handler)
{
$code = $success ? $this->successCode : $this->exceptionCode;
}
\StatsCenter::afterExecRpc($tick, $success, $code);
\SwooleTracker\Stats::afterExecRpc($tick, $success, $code);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/WebSocket/Middleware/SwooleTrackerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __init()
public function process(IFrame $frame, IMessageHandler $handler)
{
$funcName = ($this->nameHandler)($frame);
$tick = \StatsCenter::beforeExecRpc($funcName, $this->serviceName, $this->serverIp);
$tick = \SwooleTracker\Stats::beforeExecRpc($funcName, $this->serviceName, $this->serverIp);
try {
$success = $code = null;
$result = $handler->handle($frame);
Expand Down Expand Up @@ -61,7 +61,7 @@ public function process(IFrame $frame, IMessageHandler $handler)
{
$code = $success ? $this->successCode : $this->exceptionCode;
}
\StatsCenter::afterExecRpc($tick, $success, $code);
\SwooleTracker\Stats::afterExecRpc($tick, $success, $code);
}
}
}
Expand Down

0 comments on commit d63f695

Please sign in to comment.