diff --git a/README.md b/README.md index 5dac5eb..d1fe643 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # clue/connection-manager-extra [![Build Status](https://travis-ci.org/clue/php-connection-manager-extra.svg?branch=master)](https://travis-ci.org/clue/php-connection-manager-extra) This project provides _extra_ (in terms of "additional", "extraordinary", "special" and "unusual") decorators, -built on top of [ReactPHP's SocketClient](https://github.com/reactphp/socket-client). +built on top of [ReactPHP's Socket](https://github.com/reactphp/socket). **Table of Contents** @@ -22,12 +22,12 @@ built on top of [ReactPHP's SocketClient](https://github.com/reactphp/socket-cli ## Introduction -If you're not already familar with [react/socket-client](https://github.com/reactphp/socket-client), +If you're not already familar with [react/socket](https://github.com/reactphp/socket), think of it as an async (non-blocking) version of [`fsockopen()`](http://php.net/manual/en/function.fsockopen.php) or [`stream_socket_client()`](http://php.net/manual/en/function.stream-socket-client.php). I.e. before you can send and receive data to/from a remote server, you first have to establish a connection - which takes its time because it involves several steps. -In order to be able to establish several connections at the same time, [react/socket-client](https://github.com/reactphp/socket-client) provides a simple +In order to be able to establish several connections at the same time, [react/socket](https://github.com/reactphp/socket) provides a simple API to establish simple connections in an async (non-blocking) way. This project includes several classes that extend this base functionality by implementing the same simple `ConnectorInterface`. @@ -55,7 +55,7 @@ any combination thereof. This section lists all this libraries' features along with some examples. The examples assume you've [installed](#install) this library and -already [set up a `SocketClient/Connector` instance `$connector`](https://github.com/reactphp/socket-client#async-tcpip-connections). +already [set up a `Socket/Connector` instance `$connector`](https://github.com/reactphp/socket#connector). All classes are located in the `ConnectionManager\Extra` namespace. diff --git a/composer.json b/composer.json index 1f2a2e3..4aa7f83 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "clue/connection-manager-extra", - "description": "Extra decorators for creating async TCP/IP connections, built on top of ReactPHP's SocketClient", - "keywords": ["SocketClient", "network", "connection", "timeout", "delay", "reject", "repeat", "retry", "random", "acl", "firewall", "ReactPHP"], + "description": "Extra decorators for creating async TCP/IP connections, built on top of ReactPHP's Socket component", + "keywords": ["Socket", "network", "connection", "timeout", "delay", "reject", "repeat", "retry", "random", "acl", "firewall", "ReactPHP"], "homepage": "https://github.com/clue/php-connection-manager-extra", "license": "MIT", "authors": [ @@ -15,7 +15,7 @@ }, "require": { "php": ">=5.3", - "react/socket-client": "^0.7 || ^0.6", + "react/socket": "^0.7", "react/event-loop": "^0.4 || ^0.3", "react/promise": "^2.1 || ^1.2", "react/promise-timer": "^1.1" diff --git a/src/ConnectionManagerDelay.php b/src/ConnectionManagerDelay.php index 2e6a5e5..b5112c6 100644 --- a/src/ConnectionManagerDelay.php +++ b/src/ConnectionManagerDelay.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; use React\EventLoop\LoopInterface; use React\Promise\Timer; diff --git a/src/ConnectionManagerReject.php b/src/ConnectionManagerReject.php index f471043..c03f4ab 100644 --- a/src/ConnectionManagerReject.php +++ b/src/ConnectionManagerReject.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; use React\Promise; use Exception; diff --git a/src/ConnectionManagerRepeat.php b/src/ConnectionManagerRepeat.php index ddfc320..10f3f5a 100644 --- a/src/ConnectionManagerRepeat.php +++ b/src/ConnectionManagerRepeat.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; use InvalidArgumentException; use Exception; use React\Promise\Promise; diff --git a/src/ConnectionManagerSwappable.php b/src/ConnectionManagerSwappable.php index 4dece85..d133225 100644 --- a/src/ConnectionManagerSwappable.php +++ b/src/ConnectionManagerSwappable.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; // connection manager decorator which simplifies exchanging the actual connection manager during runtime class ConnectionManagerSwappable implements ConnectorInterface diff --git a/src/ConnectionManagerTimeout.php b/src/ConnectionManagerTimeout.php index b78703f..ef3eb52 100644 --- a/src/ConnectionManagerTimeout.php +++ b/src/ConnectionManagerTimeout.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; use React\EventLoop\LoopInterface; use React\Promise\Timer; use Exception; diff --git a/src/Multiple/ConnectionManagerConsecutive.php b/src/Multiple/ConnectionManagerConsecutive.php index 3459742..1474b85 100644 --- a/src/Multiple/ConnectionManagerConsecutive.php +++ b/src/Multiple/ConnectionManagerConsecutive.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra\Multiple; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; use React\Promise; use UnderflowException; use React\Promise\CancellablePromiseInterface; diff --git a/src/Multiple/ConnectionManagerSelective.php b/src/Multiple/ConnectionManagerSelective.php index 560ce47..067b06b 100644 --- a/src/Multiple/ConnectionManagerSelective.php +++ b/src/Multiple/ConnectionManagerSelective.php @@ -2,7 +2,7 @@ namespace ConnectionManager\Extra\Multiple; -use React\SocketClient\ConnectorInterface; +use React\Socket\ConnectorInterface; use React\Promise; use UnderflowException; use InvalidArgumentException; diff --git a/tests/ConnectionManagerDelayTest.php b/tests/ConnectionManagerDelayTest.php index 860ea4a..8e0532c 100644 --- a/tests/ConnectionManagerDelayTest.php +++ b/tests/ConnectionManagerDelayTest.php @@ -26,7 +26,7 @@ public function testDelayTenth() public function testCancellationOfPromiseBeforeDelayDoesNotStartConnection() { - $unused = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $unused = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $unused->expects($this->never())->method('connect'); $cm = new ConnectionManagerDelay($unused, 1.0, $this->loop); diff --git a/tests/ConnectionManagerRepeatTest.php b/tests/ConnectionManagerRepeatTest.php index 8ea7965..d2aadf3 100644 --- a/tests/ConnectionManagerRepeatTest.php +++ b/tests/ConnectionManagerRepeatTest.php @@ -21,7 +21,7 @@ public function testTwoTriesWillStartTwoConnectionAttempts() { $promise = Promise\reject(new \RuntimeException('nope')); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->exactly(2))->method('connect')->with('google.com:80')->willReturn($promise); $cm = new ConnectionManagerRepeat($connector, 2); @@ -44,7 +44,7 @@ public function testCancellationWillNotStartAnyFurtherConnections() { $pending = new Promise\Promise(function () { }, $this->expectCallableOnce()); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('google.com:80')->willReturn($pending); $cm = new ConnectionManagerRepeat($connector, 3); @@ -59,7 +59,7 @@ public function testCancellationWillNotStartAnyFurtherConnectionsIfPromiseReject throw new \RuntimeException('cancelled'); }); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('google.com:80')->willReturn($pending); $cm = new ConnectionManagerRepeat($connector, 3); diff --git a/tests/ConnectionManagerTimeoutTest.php b/tests/ConnectionManagerTimeoutTest.php index 1408659..730cbd5 100644 --- a/tests/ConnectionManagerTimeoutTest.php +++ b/tests/ConnectionManagerTimeoutTest.php @@ -68,7 +68,7 @@ public function testWillEndConnectionIfConnectionResolvesDespiteTimeout() }); }); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('www.google.com:80')->willReturn($promise); $cm = new ConnectionManagerTimeout($connector, 0.001, $this->loop); @@ -86,7 +86,7 @@ public function testCancellationOfPromiseWillCancelConnectionAttempt() throw new \RuntimeException(); }); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('www.google.com:80')->willReturn($promise); $cm = new ConnectionManagerTimeout($connector, 5.0, $this->loop); diff --git a/tests/Multiple/ConnectionManagerConcurrentTest.php b/tests/Multiple/ConnectionManagerConcurrentTest.php index ad7689b..de8797c 100644 --- a/tests/Multiple/ConnectionManagerConcurrentTest.php +++ b/tests/Multiple/ConnectionManagerConcurrentTest.php @@ -17,7 +17,7 @@ public function testWillForwardToInnerConnector() { $pending = new Promise\Promise(function() { }); - $only = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $only = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $only->expects($this->once())->method('connect')->with('google.com:80')->willReturn($pending); $connector = new ConnectionManagerConcurrent(array($only)); @@ -30,11 +30,11 @@ public function testWillForwardToInnerConnector() public function testWillCancelOtherIfOneResolves() { $resolved = Promise\resolve($this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock()); - $first = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $first = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $first->expects($this->once())->method('connect')->with('google.com:80')->willReturn($resolved); $pending = new Promise\Promise(function() { }, $this->expectCallableOnce()); - $second = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $second = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $second->expects($this->once())->method('connect')->with('google.com:80')->willReturn($pending); $connector = new ConnectionManagerConcurrent(array($first, $second)); @@ -47,12 +47,12 @@ public function testWillCancelOtherIfOneResolves() public function testWillCloseOtherIfOneResolves() { $resolved = Promise\resolve($this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock()); - $first = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $first = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $first->expects($this->once())->method('connect')->with('google.com:80')->willReturn($resolved); $slower = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock(); $slower->expects($this->once())->method('close'); - $second = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $second = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $second->expects($this->once())->method('connect')->with('google.com:80')->willReturn(Promise\resolve($slower)); $connector = new ConnectionManagerConcurrent(array($first, $second)); diff --git a/tests/Multiple/ConnectionManagerConsecutiveTest.php b/tests/Multiple/ConnectionManagerConsecutiveTest.php index ad5bc96..bcedb40 100644 --- a/tests/Multiple/ConnectionManagerConsecutiveTest.php +++ b/tests/Multiple/ConnectionManagerConsecutiveTest.php @@ -31,7 +31,7 @@ public function testWillTryAllIfEachRejects() { $rejected = Promise\reject(new \RuntimeException('nope')); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->exactly(2))->method('connect')->with('google.com:80')->willReturn($rejected); $cm = new ConnectionManagerConsecutive(array($connector, $connector)); @@ -45,7 +45,7 @@ public function testCancellationWillNotStartAnyFurtherConnections() { $pending = new Promise\Promise(function () { }, $this->expectCallableOnce()); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('google.com:80')->willReturn($pending); $cm = new ConnectionManagerConsecutive(array($connector, $connector)); diff --git a/tests/Multiple/ConnectionManagerRandomTest.php b/tests/Multiple/ConnectionManagerRandomTest.php index f75f331..773db66 100644 --- a/tests/Multiple/ConnectionManagerRandomTest.php +++ b/tests/Multiple/ConnectionManagerRandomTest.php @@ -31,7 +31,7 @@ public function testWillTryAllIfEachRejects() { $rejected = Promise\reject(new \RuntimeException('nope')); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->exactly(2))->method('connect')->with('google.com:80')->willReturn($rejected); $cm = new ConnectionManagerRandom(array($connector, $connector)); @@ -45,7 +45,7 @@ public function testCancellationWillNotStartAnyFurtherConnections() { $pending = new Promise\Promise(function () { }, $this->expectCallableOnce()); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('google.com:80')->willReturn($pending); $cm = new ConnectionManagerRandom(array($connector, $connector)); diff --git a/tests/Multiple/ConnectionManagerSelectiveTest.php b/tests/Multiple/ConnectionManagerSelectiveTest.php index a51f139..4b06d7b 100644 --- a/tests/Multiple/ConnectionManagerSelectiveTest.php +++ b/tests/Multiple/ConnectionManagerSelectiveTest.php @@ -69,7 +69,7 @@ public function provideInvalidMatcher() */ public function testInvalidMatcherThrowsException($matcher) { - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); new ConnectionManagerSelective(array( $matcher => $connector @@ -80,7 +80,7 @@ public function testExactDomainMatchForwardsToConnector() { $promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock(); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('example.com:80')->willReturn($promise); $cm = new ConnectionManagerSelective(array( @@ -96,7 +96,7 @@ public function testExactIpv6MatchForwardsToConnector() { $promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock(); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('[::1]:80')->willReturn($promise); $cm = new ConnectionManagerSelective(array( @@ -112,7 +112,7 @@ public function testExactIpv6WithPortMatchForwardsToConnector() { $promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock(); - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->once())->method('connect')->with('[::1]:80')->willReturn($promise); $cm = new ConnectionManagerSelective(array( @@ -126,7 +126,7 @@ public function testExactIpv6WithPortMatchForwardsToConnector() public function testNotMatchingDomainWillReject() { - $connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); + $connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); $connector->expects($this->never())->method('connect'); $cm = new ConnectionManagerSelective(array( diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3b379f3..b8f4ba9 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -58,7 +58,7 @@ protected function createCallableMock() protected function createConnectionManagerMock($ret) { - $mock = $this->getMockBuilder('React\SocketClient\ConnectorInterface') + $mock = $this->getMockBuilder('React\Socket\ConnectorInterface') ->getMock(); $deferred = new Deferred();