From 6f49e63f306812f74d99aa8eb94bd2698a8af96c Mon Sep 17 00:00:00 2001 From: MonkenWu Date: Sun, 1 Oct 2023 19:09:06 +0800 Subject: [PATCH] 2023.10.01 modify some error message --- src/Orchestration/Saga/Restarter/Restarter.php | 16 +++++++++++----- .../Saga/Restarter/RestarterInterface.php | 8 ++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Orchestration/Saga/Restarter/Restarter.php b/src/Orchestration/Saga/Restarter/Restarter.php index a10466c..f9e5c7f 100644 --- a/src/Orchestration/Saga/Restarter/Restarter.php +++ b/src/Orchestration/Saga/Restarter/Restarter.php @@ -75,7 +75,7 @@ public function __construct(?string $orchestratorNumber = null) public function reStartOrchestratorsByServer( string $className = null, $serverName = null, - ?bool $isRestart = false, + ?bool $reBuild = false, ?string $time = null ): array { if (is_null($className)) { @@ -96,7 +96,7 @@ public function reStartOrchestratorsByServer( ]; continue; } else { - $this->handleSingleServerRestart($singleServerName, $runtimeOrchArray, $isRestart); + $this->handleSingleServerRestart($singleServerName, $runtimeOrchArray, $reBuild); } } } elseif (is_string($serverName)) { @@ -107,7 +107,7 @@ public function reStartOrchestratorsByServer( "compensateResult" => "編排器名稱 - {$className} 不存在於 {$serverName} 內。" ]; } else { - $this->handleSingleServerRestart($serverName, $runtimeOrchArray, $isRestart); + $this->handleSingleServerRestart($serverName, $runtimeOrchArray, $reBuild); } } return $this->serverRestartResult; @@ -118,7 +118,7 @@ public function reStartOrchestratorsByServer( */ public function reStartOrchestratorsByClass( ?string $className = null, - ?bool $isRestart = false, + ?bool $reBuild = false, ?string $time = null ): array { if (is_null($className)) { @@ -127,8 +127,14 @@ public function reStartOrchestratorsByClass( $serverNameAndRuntimeOrchArray = $this->cacheInstance->getServersOrchestrator($className); + if($serverNameAndRuntimeOrchArray === null) { + return [ + "compensateResult" => "找不到編排器名稱 - {$className}。" + ]; + } + foreach ($serverNameAndRuntimeOrchArray as $serverName => $runtimeOrchArray) { - $this->handleSingleServerRestart($serverName, $runtimeOrchArray, $isRestart); + $this->handleSingleServerRestart($serverName, $runtimeOrchArray, $reBuild); } return $this->serverRestartResult; diff --git a/src/Orchestration/Saga/Restarter/RestarterInterface.php b/src/Orchestration/Saga/Restarter/RestarterInterface.php index 76296fc..0aa57f6 100644 --- a/src/Orchestration/Saga/Restarter/RestarterInterface.php +++ b/src/Orchestration/Saga/Restarter/RestarterInterface.php @@ -11,7 +11,7 @@ interface RestarterInterface * * @param string|null $className * @param array|string $serverName - * @param bool|null $isRestart If pass in true in this param, the restarter will restart the runtime orchestrator after compensation. + * @param bool|null $reBuild If pass in true in this param, the restarter will restart the runtime orchestrator after compensation. * Otherwise, The restarter will only run the compensation for this runtime orchestrator. * @param string|null $time * @return array @@ -19,7 +19,7 @@ interface RestarterInterface public function reStartOrchestratorsByServer( string $className = null, $serverName = null, - ?bool $isRestart = false, + ?bool $reBuild = false, ?string $time = null ): array; @@ -27,13 +27,13 @@ public function reStartOrchestratorsByServer( * Re-start all same className runtime orchestrator in Redis no matter what the serverName is. * * @param string|null $className - * @param boolean|null $isRestart + * @param boolean|null $reBuild * @param string|null $time * @return array */ public function reStartOrchestratorsByClass( string $className = null, - ?bool $isRestart = false, + ?bool $reBuild = false, ?string $time = null ): array;