Skip to content

Commit 769ad10

Browse files
committed
Documentation for blocking API
1 parent 9b403e5 commit 769ad10

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ ViewVC web interface.
5454
$client->fetchDirectory($path, $revision = null);
5555
$client->fetchFile($path, $revision = null);
5656
$client->fetchPatch($path, $r1, $r2);
57+
$client->fetchLog($path, $revision = null);
5758

5859
// many more…
5960
```
6061

62+
All actions support async operation by returning [promises](#promises).
63+
6164
Listing all available actions is out of scope here, please refer to the [class outline](src/Client.php).
6265

63-
#### Processing
66+
#### Promises
6467

6568
Sending requests is async (non-blocking), so you can actually send multiple requests in parallel.
6669
ViewVC will respond to each request with a response message, the order is not guaranteed.
@@ -77,6 +80,35 @@ $client->fetchFile($path)->then(
7780
});
7881
```
7982

83+
If this looks strange to you, you can also use the more traditional [blocking API](#blocking).
84+
85+
#### Blocking
86+
87+
As stated above, this library provides you a powerful, async API by default.
88+
89+
If, however, you want to integrate this into your traditional, blocking environment,
90+
you should look into also using [clue/block-react](https://github.com/clue/php-block-react).
91+
92+
The resulting blocking code could look something like this:
93+
94+
```php
95+
$loop = React\EventLoop\Factory::create();
96+
$browser = new Clue\React\Buzz\Browser($loop);
97+
$blocker = new Clue\React\Block\Blocker($loop);
98+
99+
$client = new Client($url /* change me */, $browser);
100+
$promise = $client->fetchFile($path /* change me */);
101+
102+
try {
103+
$contents = $blocker->awaitOne($promise);
104+
// file contents received
105+
} catch (Exception $e) {
106+
// an error occured while executing the request
107+
}
108+
```
109+
110+
Refer to [clue/block-react](https://github.com/clue/php-block-react#readme) for more details.
111+
80112
## Install
81113

82114
The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)

0 commit comments

Comments
 (0)