@@ -70,8 +70,9 @@ discard block |
||
| 70 | 70 | $this->_instances = new \SplObjectStorage(); |
| 71 | 71 | |
| 72 | 72 | // Attach a state to each instance |
| 73 | - foreach ($this->_configuration->getInstances() as $instance) |
|
| 74 | - $this->_instances->attach($instance, new InstanceState()); |
|
| 73 | + foreach ($this->_configuration->getInstances() as $instance) { |
|
| 74 | + $this->_instances->attach($instance, new InstanceState()); |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | // Start the persistence manager |
| 77 | 78 | $this->_persistenceManager = new PersistenceManager($logger); |
@@ -147,20 +148,24 @@ discard block |
||
| 147 | 148 | ]); |
| 148 | 149 | |
| 149 | 150 | // Persist connections |
| 150 | - foreach ($instanceStatus->getConnections() as $connection) |
|
| 151 | - $this->_persistenceManager->onConnectionSeen($instanceName, $connection); |
|
| 151 | + foreach ($instanceStatus->getConnections() as $connection) { |
|
| 152 | + $this->_persistenceManager->onConnectionSeen($instanceName, $connection); |
|
| 153 | + } |
|
| 152 | 154 | |
| 153 | 155 | // Persist inputs |
| 154 | - foreach($instanceStatus->getInputs() as $input) |
|
| 155 | - $this->_persistenceManager->onInputSeen($instanceName, $input); |
|
| 156 | + foreach($instanceStatus->getInputs() as $input) { |
|
| 157 | + $this->_persistenceManager->onInputSeen($instanceName, $input); |
|
| 158 | + } |
|
| 156 | 159 | |
| 157 | 160 | // Persist running subscriptions |
| 158 | - foreach ($instanceStatus->getSubscriptions() as $subscription) |
|
| 159 | - $this->_persistenceManager->onSubscriptionSeen($instanceName, $subscription); |
|
| 161 | + foreach ($instanceStatus->getSubscriptions() as $subscription) { |
|
| 162 | + $this->_persistenceManager->onSubscriptionSeen($instanceName, $subscription); |
|
| 163 | + } |
|
| 160 | 164 | |
| 161 | 165 | // Handle subscription state changes |
| 162 | - foreach ($instanceStatus->getSubscriptionStateChanges() as $subscriptionStateChange) |
|
| 163 | - $this->_persistenceManager->onSubscriptionStateChange($instanceName, $subscriptionStateChange); |
|
| 166 | + foreach ($instanceStatus->getSubscriptionStateChanges() as $subscriptionStateChange) { |
|
| 167 | + $this->_persistenceManager->onSubscriptionStateChange($instanceName, $subscriptionStateChange); |
|
| 168 | + } |
|
| 164 | 169 | } |
| 165 | 170 | |
| 166 | 171 | // Broadcast the status messages to all connected clients |
@@ -208,8 +213,7 @@ discard block |
||
| 208 | 213 | |
| 209 | 214 | $instanceState->setReachability(InstanceState::REACHABLE); |
| 210 | 215 | } |
| 211 | - } |
|
| 212 | - catch (\Exception $e) |
|
| 216 | + } catch (\Exception $e) |
|
| 213 | 217 | { |
| 214 | 218 | // Mark the instance as unreachable |
| 215 | 219 | $message = 'Instance {instanceName} not reachable, will wait for {cycles} cycles before retrying. |
@@ -223,8 +227,7 @@ discard block |
||
| 223 | 227 | |
| 224 | 228 | $instanceState->setReachability(InstanceState::UNREACHABLE); |
| 225 | 229 | } |
| 226 | - } |
|
| 227 | - else |
|
| 230 | + } else |
|
| 228 | 231 | { |
| 229 | 232 | // Wait for some cycles and then mark unreachable instances as maybe reachable |
| 230 | 233 | if ($instanceState->getRetryCount() === self::UNREACHABLE_CYCLES_UNTIL_RETRY - 1) |
@@ -235,9 +238,9 @@ discard block |
||
| 235 | 238 | $this->_logger->info('Retrying instance {instanceName} during next cycle', [ |
| 236 | 239 | 'instanceName' => $instanceName, |
| 237 | 240 | ]); |
| 241 | + } else { |
|
| 242 | + $instanceState->incrementRetryCount(); |
|
| 238 | 243 | } |
| 239 | - else |
|
| 240 | - $instanceState->incrementRetryCount(); |
|
| 241 | 244 | } |
| 242 | 245 | } |
| 243 | 246 | |