Skip to content

Commit

Permalink
Squashed 'src/rpc/' changes from c017bf5..e782bc1
Browse files Browse the repository at this point in the history
e782bc1 Upstream travis ci config (#160)
a58ef2c Fix rpc unit test (#159)
a47e885 Fix ci (#158)
92c9b75 fix ci  (#157)
fd461c6 rpc component add travis ci config (#156)
8f02304 修复非server环境下使用rpc服务时抛出Call to a member function getTcpSetting() on null 的BUG (#155)
0eaec24 修复Json Validator会失效的BUG (#153)

git-subtree-dir: src/rpc
git-subtree-split: e782bc15cd72b710131bda795e4871b5606ea4a0
  • Loading branch information
swoft-bot committed Oct 6, 2018
1 parent 1b292d9 commit e1852b7
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 11 deletions.
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: php

php:
- 7.0
- 7.1
- 7.2

install:
- wget https://github.com/swoole/swoole-src/archive/v4.0.2.tar.gz -O swoole.tar.gz && mkdir -p swoole && tar -xf swoole.tar.gz -C swoole --strip-components=1 && rm swoole.tar.gz && cd swoole && phpize && ./configure && make -j$(nproc) && make install && cd -
- echo "extension = swoole.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

before_script:
- phpenv config-rm xdebug.ini
- composer update

script: composer test
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"repositories": [
{
"type": "composer",
"url": "https://packagist.phpcomposer.com"
"url": "https://packagist.laravel-china.org"
}
],
"scripts": {
Expand Down
13 changes: 4 additions & 9 deletions src/Packer/EofTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ trait EofTrait
/**
* @return string
*/
public function getEof():string
public function getEof(): string
{
$eof = '';
$tcpSettings = App::$server->getTcpSetting();
if (isset($tcpSettings['package_eof'])) {
$eof = $tcpSettings['package_eof'];
}
return $eof;
$properties = App::getAppProperties();
return $properties->get('server.tcp.package_eof', '');
}

}
}
17 changes: 16 additions & 1 deletion test/Cases/JsonPackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,31 @@ public function pack()
'1',
1,
1.1234,
bool,
false,
true,
[
'a',
1,
false,
true,
1.1234
],
new \ArrayObject([
'a',
1,
false,
true,
1.1234
]),
];
$packedData = $packer->pack($data);
$this->assertInternalType('string', $packedData);
$this->assertJson(\json_encode($data), $packedData);
}

public function testEof()
{
$packer = new JsonPacker();
$this->assertEquals("\r\n", $packer->getEof());
}
}
62 changes: 62 additions & 0 deletions test/config/server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://doc.swoft.org
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

return [
'server' => [
'pfile' => env('PFILE', '/tmp/swoft.pid'),
'pname' => env('PNAME', 'php-swoft'),
'tcpable' => env('TCPABLE', true),
'cronable' => env('CRONABLE', false),
'autoReload' => env('AUTO_RELOAD', true),
],
'tcp' => [
'host' => env('TCP_HOST', '0.0.0.0'),
'port' => env('TCP_PORT', 8099),
'mode' => env('TCP_MODE', SWOOLE_PROCESS),
'type' => env('TCP_TYPE', SWOOLE_SOCK_TCP),
'package_max_length' => env('TCP_PACKAGE_MAX_LENGTH', 2048),
'open_eof_check' => env('TCP_OPEN_EOF_CHECK', false),
'package_eof' => "\r\n",
],
'http' => [
'host' => env('HTTP_HOST', '0.0.0.0'),
'port' => env('HTTP_PORT', 80),
'mode' => env('HTTP_MODE', SWOOLE_PROCESS),
'type' => env('HTTP_TYPE', SWOOLE_SOCK_TCP),
],
'ws' => [
// enable handle http request ?
'enable_http' => env('WS_ENABLE_HTTP', true),
// other settings will extend the 'http' config
// you can define separately to overwrite existing settings
],
'crontab' => [
'task_count' => env('CRONTAB_TASK_COUNT', 1024),
'task_queue' => env('CRONTAB_TASK_QUEUE', 2048),
],
'setting' => [
'worker_num' => env('WORKER_NUM', 1),
'max_request' => env('MAX_REQUEST', 10000),
'daemonize' => env('DAEMONIZE', 0),
'dispatch_mode' => env('DISPATCH_MODE', 2),
'log_file' => env('LOG_FILE', '@runtime/logs/swoole.log'),
'task_worker_num' => env('TASK_WORKER_NUM', 1),
'package_max_length' => env('PACKAGE_MAX_LENGTH', 2048),
'upload_tmp_dir' => env('UPLOAD_TMP_DIR', '@runtime/uploadfiles'),
'document_root' => env('DOCUMENT_ROOT', BASE_PATH . '/public'),
'enable_static_handler' => env('ENABLE_STATIC_HANDLER', true),
'open_http2_protocol' => env('OPEN_HTTP2_PROTOCOL', false),
'ssl_cert_file' => env('SSL_CERT_FILE', ''),
'ssl_key_file' => env('SSL_KEY_FILE', ''),
'task_ipc_mode' => env('TASK_IPC_MODE', 1),
'message_queue_key' => env('MESSAGE_QUEUE_KEY', 0x70001001),
'task_tmpdir' => env('TASK_TMPDIR', '/tmp'),
],
];

0 comments on commit e1852b7

Please sign in to comment.