Skip to content

Commit 6718cb4

Browse files
authored
Merge pull request #61 from clue-labs/legacy
Remove all deprecated APIs
2 parents e7f99fb + 9d5c2b6 commit 6718cb4

File tree

12 files changed

+21
-208
lines changed

12 files changed

+21
-208
lines changed

README.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ local Redis server and send some requests:
4646
$loop = React\EventLoop\Factory::create();
4747
$factory = new Factory($loop);
4848

49-
$factory->createClient('localhost:6379')->then(function (Client $client) use ($loop) {
49+
$factory->createClient('localhost')->then(function (Client $client) use ($loop) {
5050
$client->set('greeting', 'Hello world');
5151
$client->append('greeting', '!');
5252

@@ -98,15 +98,9 @@ $connector = new \React\Socket\Connector($loop, array(
9898
$factory = new Factory($loop, $connector);
9999
```
100100

101-
> Legacy notice: As of `v1.2.0`, the optional connector should implement the new
102-
`React\Socket\ConnectorInterface`. For BC reasons it also accepts the
103-
legacy `React\SocketClient\ConnectorInterface`.
104-
This legacy API will be removed in a future `v2.0.0` version, so it's highly
105-
recommended to upgrade to the above API.
106-
107101
#### createClient()
108102

109-
The `createClient($redisUri = null)` method can be used to create a new [`Client`](#client).
103+
The `createClient($redisUri)` method can be used to create a new [`Client`](#client).
110104
It helps with establishing a plain TCP/IP or secure TLS connection to Redis
111105
and optionally authenticating (AUTH) and selecting the right database (SELECT).
112106

@@ -143,12 +137,6 @@ $factory->createClient('redis://ignored:h%40llo@localhost');
143137
$factory->createClient('redis://localhost?password=h%40llo');
144138
```
145139

146-
> Legacy notice: The `redis://` scheme is defined and preferred as of `v1.2.0`.
147-
For BC reasons, the `Factory` defaults to the `tcp://` scheme in which case
148-
the authentication details would include the otherwise unused username.
149-
This legacy API will be removed in a future `v2.0.0` version, so it's highly
150-
recommended to upgrade to the above API.
151-
152140
You can optionally include a path that will be used to select (SELECT command) the right database:
153141

154142
```php
@@ -164,15 +152,6 @@ You can use the [standard](https://www.iana.org/assignments/uri-schemes/prov/red
164152
$factory->createClient('rediss://redis.example.com:6340');
165153
```
166154

167-
[Deprecated] You can omit the complete URI if you want to connect to the default
168-
address `redis://localhost:6379`. This legacy API will be removed in a future
169-
`v2.0.0` version, so it's highly recommended to upgrade to the above API.
170-
171-
```php
172-
// deprecated
173-
$factory->createClient();
174-
```
175-
176155
### Client
177156

178157
The `Client` is responsible for exchanging messages with Redis

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"react/event-loop": "0.3.*|0.4.*",
1616
"react/promise": "^2.0 || ^1.1",
1717
"react/socket": "^0.7",
18-
"react/socket-client": "^0.7",
1918
"clue/redis-protocol": "0.3.*",
2019
"evenement/evenement": "~1.0|~2.0"
2120
},

examples/cli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
echo '# connecting to redis...' . PHP_EOL;
1414

15-
$factory->createClient()->then(function (Client $client) use ($loop) {
15+
$factory->createClient('localhost')->then(function (Client $client) use ($loop) {
1616
echo '# connected! Entering interactive mode, hit CTRL-D to quit' . PHP_EOL;
1717

1818
$client->on('data', function (ModelInterface $data) {

examples/incr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$loop = React\EventLoop\Factory::create();
99
$factory = new Factory($loop);
1010

11-
$factory->createClient()->then(function (Client $client) {
11+
$factory->createClient('localhost')->then(function (Client $client) {
1212
$client->incr('test');
1313

1414
$client->get('test')->then(function ($result) {

examples/monitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$loop = React\EventLoop\Factory::create();
1010
$factory = new Factory($loop);
1111

12-
$factory->createClient()->then(function (Client $client) {
12+
$factory->createClient('localhost')->then(function (Client $client) {
1313
$client->monitor()->then(function ($result) {
1414
echo 'Now monitoring all commands' . PHP_EOL;
1515
});

examples/publish.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use Clue\React\Redis\Client;
44
use Clue\React\Redis\Factory;
5-
use Clue\Redis\Protocol\Model\StatusReply;
65

76
require __DIR__ . '/../vendor/autoload.php';
87

@@ -12,7 +11,7 @@
1211
$channel = isset($argv[1]) ? $argv[1] : 'channel';
1312
$message = isset($argv[2]) ? $argv[2] : 'message';
1413

15-
$factory->createClient()->then(function (Client $client) use ($channel, $message) {
14+
$factory->createClient('localhost')->then(function (Client $client) use ($channel, $message) {
1615
$client->publish($channel, $message)->then(function ($received) {
1716
echo 'successfully published. Received by ' . $received . PHP_EOL;
1817
});

examples/subscribe.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use Clue\React\Redis\Client;
44
use Clue\React\Redis\Factory;
5-
use Clue\Redis\Protocol\Model\StatusReply;
65

76
require __DIR__ . '/../vendor/autoload.php';
87

@@ -11,7 +10,7 @@
1110

1211
$channel = isset($argv[1]) ? $argv[1] : 'channel';
1312

14-
$factory->createClient()->then(function (Client $client) use ($channel) {
13+
$factory->createClient('localhost')->then(function (Client $client) use ($channel) {
1514
$client->subscribe($channel)->then(function () {
1615
echo 'Now subscribed to channel ' . PHP_EOL;
1716
});

src/ConnectionUpcaster.php

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/ConnectorUpcaster.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Factory.php

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,14 @@ class Factory
1818

1919
/**
2020
* @param LoopInterface $loop
21-
* @param ConnectorInterface|\React\SocketClient\ConnectorInterface|null $connector
22-
* [optional] Connector to use. Should be `null` in order to use default
23-
* Connector. Passing a `\React\SocketClient\ConnectorInterface` is
24-
* deprecated and only supported for BC reasons and will be removed in
25-
* future versions.
21+
* @param ConnectorInterface|null $connector [optional] Connector to use.
22+
* Should be `null` in order to use default Connector.
2623
* @param ProtocolFactory|null $protocol
2724
*/
28-
public function __construct(LoopInterface $loop, $connector = null, ProtocolFactory $protocol = null)
25+
public function __construct(LoopInterface $loop, ConnectorInterface $connector = null, ProtocolFactory $protocol = null)
2926
{
3027
if ($connector === null) {
3128
$connector = new Connector($loop);
32-
} elseif (!$connector instanceof ConnectorInterface) {
33-
$connector = new ConnectorUpcaster($connector);
3429
}
3530

3631
if ($protocol === null) {
@@ -44,12 +39,10 @@ public function __construct(LoopInterface $loop, $connector = null, ProtocolFact
4439
/**
4540
* create redis client connected to address of given redis instance
4641
*
47-
* @param string|null $target Redis server URI to connect to. Not passing
48-
* this parameter is deprecated and only supported for BC reasons and
49-
* will be removed in future versions.
42+
* @param string $target Redis server URI to connect to
5043
* @return \React\Promise\PromiseInterface resolves with Client or rejects with \Exception
5144
*/
52-
public function createClient($target = null)
45+
public function createClient($target)
5346
{
5447
try {
5548
$parts = $this->parseUrl($target);
@@ -95,21 +88,18 @@ function ($error) use ($client) {
9588
}
9689

9790
/**
98-
* @param string|null $target
91+
* @param string $target
9992
* @return array with keys host, port, auth and db
10093
* @throws InvalidArgumentException
10194
*/
10295
private function parseUrl($target)
10396
{
104-
if ($target === null) {
105-
$target = 'tcp://127.0.0.1';
106-
}
10797
if (strpos($target, '://') === false) {
108-
$target = 'tcp://' . $target;
98+
$target = 'redis://' . $target;
10999
}
110100

111101
$parts = parse_url($target);
112-
if ($parts === false || !isset($parts['scheme'], $parts['host']) || !in_array($parts['scheme'], array('tcp', 'redis', 'rediss'))) {
102+
if ($parts === false || !isset($parts['scheme'], $parts['host']) || !in_array($parts['scheme'], array('redis', 'rediss'))) {
113103
throw new InvalidArgumentException('Given URL can not be parsed');
114104
}
115105

@@ -121,15 +111,8 @@ private function parseUrl($target)
121111
$parts['host'] = '127.0.0.1';
122112
}
123113

124-
$auth = null;
125-
if (isset($parts['user']) && $parts['scheme'] === 'tcp') {
126-
$auth = rawurldecode($parts['user']);
127-
}
128114
if (isset($parts['pass'])) {
129-
$auth .= ($parts['scheme'] === 'tcp' ? ':' : '') . rawurldecode($parts['pass']);
130-
}
131-
if ($auth !== null) {
132-
$parts['auth'] = $auth;
115+
$parts['auth'] = rawurldecode($parts['pass']);
133116
}
134117

135118
if (isset($parts['path']) && $parts['path'] !== '') {

0 commit comments

Comments
 (0)