1111class ConnectionManagerRepeat implements ConnectorInterface
1212{
1313 protected $ connectionManager ;
14- protected $ maximumRepetitions ;
14+ protected $ maximumTries ;
1515
16- public function __construct (ConnectorInterface $ connectionManager , $ maximumRepetitons )
16+ public function __construct (ConnectorInterface $ connectionManager , $ maximumTries )
1717 {
18- if ($ maximumRepetitons < 1 ) {
19- throw new InvalidArgumentException ('Maximum number of repetitions must be >= 1 ' );
18+ if ($ maximumTries < 1 ) {
19+ throw new InvalidArgumentException ('Maximum number of tries must be >= 1 ' );
2020 }
2121 $ this ->connectionManager = $ connectionManager ;
22- $ this ->maximumRepetitions = $ maximumRepetitons ;
22+ $ this ->maximumTries = $ maximumTries ;
2323 }
2424
2525 public function create ($ host , $ port )
2626 {
27- return $ this ->tryConnection ($ this ->maximumRepetitions , $ host , $ port );
28- }
29-
30- public function tryConnection ($ repeat , $ host , $ port )
31- {
32- $ tries = $ repeat + 1 ;
27+ $ tries = $ this ->maximumTries ;
3328 $ connector = $ this ->connectionManager ;
3429
3530 return new Promise (function ($ resolve , $ reject ) use ($ host , $ port , &$ pending , &$ tries , $ connector ) {
@@ -39,7 +34,7 @@ public function tryConnection($repeat, $host, $port)
3934 $ pending = $ connector ->create ($ host , $ port );
4035 $ pending ->then ($ resolve , $ try );
4136 } else {
42- $ reject (new Exception ('Connection still fails even after repeating ' , 0 , $ error ));
37+ $ reject (new Exception ('Connection still fails even after retrying ' , 0 , $ error ));
4338 }
4439 };
4540
0 commit comments