-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加RpcClient可以自定义配置的能力 (swoft-cloud/swoft-component#152)
* 增加测试使用的配置 * 完善单测配置 * 完善单测 * 增加components配置 * 增加大文本返回时,client正确接收的单测 * 允许用户在tcp.client中自定义client的配置 * 测试配置,增加open_eof_split * Update server.php * 更改组件加载配置 * 更改组件加载配置 * Update ServiceConnection.php
- Loading branch information
1 parent
e1aee2a
commit 83bcfaf
Showing
18 changed files
with
287 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Rpc\Testing\Breaker; | ||
|
||
use Swoft\Sg\Bean\Annotation\Breaker; | ||
use Swoft\Bean\Annotation\Value; | ||
use Swoft\Sg\Circuit\CircuitBreaker; | ||
|
||
/** | ||
* the breaker of default | ||
* | ||
* @Breaker("breaker") | ||
*/ | ||
class ServiceBreaker extends CircuitBreaker | ||
{ | ||
/** | ||
* @var string 服务名称 | ||
*/ | ||
public $serviceName = 'breakerService'; | ||
|
||
/** | ||
* The number of successive failures | ||
* If the arrival, the state switch to open | ||
* | ||
* @Value(name="${config.breaker.default.failCount}") | ||
* @var int | ||
*/ | ||
protected $switchToFailCount = 3; | ||
|
||
/** | ||
* The number of successive successes | ||
* If the arrival, the state switch to close | ||
* | ||
* @Value(name="${config.breaker.default.successCount}") | ||
* @var int | ||
*/ | ||
protected $switchToSuccessCount = 3; | ||
|
||
/** | ||
* Switch close to open delay time | ||
* The unit is milliseconds | ||
* | ||
* @Value(name="${config.breaker.default.delayTime}") | ||
* @var int | ||
*/ | ||
protected $delaySwitchTimer = 500; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
namespace SwoftTest\Rpc\Testing\Clients; | ||
|
||
use Swoft\Bean\Annotation\Bean; | ||
use Swoft\Rpc\Client\Bean\Annotation\Reference; | ||
use SwoftTest\Rpc\Testing\Lib\DemoServiceInterface; | ||
|
||
/** | ||
* Class DemoServiceClient | ||
* @Bean | ||
* @method version | ||
* @method longMessage($string) | ||
*/ | ||
class DemoServiceClient | ||
{ | ||
/** | ||
* @Reference(name="service.demo", fallback="demoFallback", breaker="breaker") | ||
* @var DemoServiceInterface | ||
*/ | ||
protected $demoService; | ||
|
||
public function __call($name, $arguments) | ||
{ | ||
return $this->demoService->$name(...$arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Rpc\Testing\Fallback; | ||
|
||
|
||
use Swoft\Sg\Bean\Annotation\Fallback; | ||
use Swoft\Core\ResultInterface; | ||
use SwoftTest\Rpc\Testing\Lib\DemoServiceInterface; | ||
|
||
/** | ||
* Class DemoServiceFallback | ||
* @Fallback("demoFallback") | ||
* @method ResultInterface deferVersion | ||
* @method ResultInterface deferLongMessage($string) | ||
*/ | ||
class DemoServiceFallback implements DemoServiceInterface | ||
{ | ||
public function version() | ||
{ | ||
return 'versionFallback'; | ||
} | ||
|
||
public function longMessage($string) | ||
{ | ||
return 'bigMessageFallBack'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Rpc\Testing\Lib; | ||
|
||
use Swoft\Core\ResultInterface; | ||
|
||
/** | ||
* Interface DemoServiceInterface | ||
* @method ResultInterface deferVersion() | ||
* @method ResultInterface deferLongMessage($string) | ||
*/ | ||
interface DemoServiceInterface | ||
{ | ||
public function version(); | ||
|
||
public function longMessage($string); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace SwoftTest\Rpc\Testing\Pool\Config; | ||
|
||
use Swoft\Bean\Annotation\Bean; | ||
use Swoft\Bean\Annotation\Value; | ||
use Swoft\Pool\PoolProperties; | ||
|
||
/** | ||
* Class DemoServicePoolConfig | ||
* @Bean | ||
* @package SwoftTest\Rpc\Client\Testing\Pool\Config | ||
*/ | ||
class DemoServicePoolConfig extends PoolProperties | ||
{ | ||
protected $name = 'service.demo'; | ||
|
||
protected $uri = [ | ||
'127.0.0.1:8099' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
namespace SwoftTest\Rpc\Testing\Pool; | ||
|
||
use Swoft\Bean\Annotation\Inject; | ||
use Swoft\Bean\Annotation\Pool; | ||
use Swoft\Rpc\Client\Pool\ServicePool as SwoftServicePool; | ||
use SwoftTest\Rpc\Testing\Pool\Config\DemoServicePoolConfig; | ||
|
||
/** | ||
* Class DemoServicePool | ||
* @Pool(name="service.demo") | ||
* @package SwoftTest\Rpc\Testing\Pool | ||
*/ | ||
class DemoServicePool extends SwoftServicePool | ||
{ | ||
/** | ||
* @Inject | ||
* @var DemoServicePoolConfig | ||
*/ | ||
protected $poolConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
namespace SwoftTest\Rpc\Testing\Services; | ||
|
||
use SwoftTest\Rpc\Testing\Lib\DemoServiceInterface; | ||
use Swoft\Rpc\Server\Bean\Annotation\Service; | ||
use Swoft\Core\ResultInterface; | ||
|
||
/** | ||
* Class DemoService | ||
* @Service() | ||
* @method ResultInterface deferVersion() | ||
* @method ResultInterface deferLongMessage($string) | ||
* @package App\Services | ||
*/ | ||
class DemoService implements DemoServiceInterface | ||
{ | ||
public function version() | ||
{ | ||
return '1.0.0'; | ||
} | ||
|
||
public function longMessage($string) | ||
{ | ||
$res = ''; | ||
for ($i = 0; $i < 50000; $i++) { | ||
$res .= $string; | ||
} | ||
return $res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.