Skip to content

Commit 8052864

Browse files
committed
Merge pull request clue#19 from clue/client-interface
Add Client interface
2 parents 9c7bf0c + 7e782ce commit 8052864

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

src/Client.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Clue\React\Redis;
4+
5+
use Evenement\EventEmitterInterface;
6+
use React\Promise\PromiseInterface;
7+
use Clue\Redis\Protocol\Model\ModelInterface;
8+
9+
/**
10+
* Simple interface for executing redis commands
11+
*
12+
* @event message(ModelInterface $model, Client $thisClient)
13+
*/
14+
interface Client extends EventEmitterInterface
15+
{
16+
/**
17+
* Invoke the given command and return a Promise that will be resolved when the request has been replied to
18+
*
19+
* This is a magic method that will be invoked when calling any redis
20+
* command on this instance.
21+
*
22+
* @param string $name
23+
* @param string[] $args
24+
* @return PromiseInterface
25+
*/
26+
public function __call($name, $args);
27+
28+
/**
29+
* Checks if the client is busy, i.e. still has any requests pending
30+
*
31+
* @return boolean
32+
*/
33+
public function isBusy();
34+
35+
/**
36+
* end connection once all pending requests have been replied to
37+
*
38+
* @uses self::close() once all replies have been received
39+
* @see self::close() for closing the connection immediately
40+
*/
41+
public function end();
42+
43+
/**
44+
* close connection immediately
45+
*
46+
* @see self::end() for closing the connection once the client is idle
47+
*/
48+
public function close();
49+
}

src/StreamingClient.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Clue\Redis\Protocol\Model\ErrorReply;
1616
use Clue\Redis\Protocol\Model\ModelInterface;
1717

18-
class StreamingClient extends EventEmitter
18+
class StreamingClient extends EventEmitter implements Client
1919
{
2020
private $stream;
2121
private $parser;
@@ -108,12 +108,6 @@ public function isBusy()
108108
return !!$this->requests;
109109
}
110110

111-
/**
112-
* end connection once all pending requests have been replied to
113-
*
114-
* @uses self::close() once all replies have been received
115-
* @see self::close() for closing the connection immediately
116-
*/
117111
public function end()
118112
{
119113
$this->ending = true;

0 commit comments

Comments
 (0)