Merge branch 'master' of git.int.haowumc.com:composer/php-json-rpc
This commit is contained in:
commit
99f5b6c8f8
|
@ -7,7 +7,8 @@
|
|||
"illuminate/support": "^5.5",
|
||||
"illuminate/http": "^5.5",
|
||||
"monolog/monolog": "^1.24",
|
||||
"itxq/api-doc-php": "^1.1"
|
||||
"itxq/api-doc-php": "^1.1",
|
||||
"influxdb/influxdb-php": "^1.14"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
70
composer.lock
generated
70
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c8f285c2463b3be4f6b2e70209334571",
|
||||
"content-hash": "dcf38bcb34b2690d5c6cdd46c9cb1280",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
|
@ -561,6 +561,72 @@
|
|||
"homepage": "https://laravel.com",
|
||||
"time": "2019-01-07T13:39:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdb/influxdb-php",
|
||||
"version": "1.14.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/influxdata/influxdb-php.git",
|
||||
"reference": "570bd5cdedb9b1c1628dceea5785bc40e08f7e48"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/570bd5cdedb9b1c1628dceea5785bc40e08f7e48",
|
||||
"reference": "570bd5cdedb9b1c1628dceea5785bc40e08f7e48",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^6.0",
|
||||
"php": "^5.5 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"suggest": {
|
||||
"stefanotorresi/influxdb-php-async": "An asyncronous client for InfluxDB, implemented via ReactPHP."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"InfluxDB\\": "src/InfluxDB"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gianluca Arbezzano",
|
||||
"email": "gianarb92@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Daniel Martinez",
|
||||
"email": "danimartcas@hotmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Stephen Hoogendijk",
|
||||
"email": "stephen@tca0.nl"
|
||||
}
|
||||
],
|
||||
"description": "InfluxDB client library for PHP",
|
||||
"keywords": [
|
||||
"client",
|
||||
"influxdata",
|
||||
"influxdb",
|
||||
"influxdb class",
|
||||
"influxdb client",
|
||||
"influxdb library",
|
||||
"time series"
|
||||
],
|
||||
"time": "2018-07-06T10:13:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "itxq/api-doc-php",
|
||||
"version": "v1.1.1",
|
||||
|
@ -1482,7 +1548,7 @@
|
|||
},
|
||||
{
|
||||
"name": "Gert de Pagter",
|
||||
"email": "BackEndTea@gmail.com"
|
||||
"email": "backendtea@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for ctype functions",
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
namespace JsonRpc\Middleware;
|
||||
|
||||
use Closure;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use InfluxDB\Database;
|
||||
use InfluxDB\Point;
|
||||
|
||||
/**
|
||||
* Class TunnelMiddleware
|
||||
|
@ -27,17 +30,30 @@ class TunnelMiddleware
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $response
|
||||
*/
|
||||
public function terminate($request, $response)
|
||||
{
|
||||
//过滤tool返回结果
|
||||
if ($response instanceof JsonResponse)
|
||||
{
|
||||
$content = $response->getOriginalContent();
|
||||
if (isset($content['error'])){
|
||||
app('rpc.logger')->info('rpc tunnel', [$content['error']['code']]);
|
||||
} else {
|
||||
app('rpc.logger')->info('rpc tunnel', [200]);
|
||||
}
|
||||
$status = isset($content['error']) ? $content['error']['code'] : 200;
|
||||
|
||||
$client = new \InfluxDB\Client('http://localhost', '8086');
|
||||
$database = $client->selectDB('rpc_monitor');
|
||||
$points = array(
|
||||
new Point(
|
||||
'monitor',
|
||||
0.64,
|
||||
['app' =>env('APP_NAME'), 'status' => $status],
|
||||
['content' => $request->getContent()]
|
||||
)
|
||||
);
|
||||
$result = $database->writePoints($points, Database::PRECISION_SECONDS);
|
||||
app('rpc.logger')->info('rpc tunnel ctx ' [$result]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ class JsonRpcServer extends JsonRpcBase
|
|||
if (!$this->isEnoughParameter($class, $function, $params)) {
|
||||
return $this->error(self::Rpc_Error_Invalid_Params);
|
||||
}
|
||||
$this->request->attributes->add(['tunnel_method' => $method, 'tunnel_params' => $params]);
|
||||
app('rpc.logger')->info('server', [$id, $class,$method, $params]);
|
||||
$ret = call_user_func_array([(new $class($id, $this->request)), $function], $params);
|
||||
app('rpc.logger')->info('server_result', [$id, $ret]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user