Skip to content

Commit 808d08c

Browse files
authored
Merge pull request #137 from clue-labs/executor-docs
API documentation for ExecutorInterface
2 parents 9f38d49 + 309ab96 commit 808d08c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/Query/ExecutorInterface.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,40 @@
44

55
interface ExecutorInterface
66
{
7+
/**
8+
* Executes a query and will return a response message
9+
*
10+
* It returns a Promise which either fulfills with a response
11+
* `React\Dns\Model\Message` on success or rejects with an `Exception` if
12+
* the query is not successful. A response message may indicate an error
13+
* condition in its `rcode`, but this is considered a valid response message.
14+
*
15+
* ```php
16+
* $executor->query($query)->then(
17+
* function (React\Dns\Model\Message $response) {
18+
* // response message successfully received
19+
* var_dump($response->rcode, $response->answers);
20+
* },
21+
* function (Exception $error) {
22+
* // failed to query due to $error
23+
* }
24+
* );
25+
* ```
26+
*
27+
* The returned Promise MUST be implemented in such a way that it can be
28+
* cancelled when it is still pending. Cancelling a pending promise MUST
29+
* reject its value with an Exception. It SHOULD clean up any underlying
30+
* resources and references as applicable.
31+
*
32+
* ```php
33+
* $promise = $executor->query($query);
34+
*
35+
* $promise->cancel();
36+
* ```
37+
*
38+
* @param Query $query
39+
* @return \React\Promise\PromiseInterface<\React\Dns\Model\Message,\Exception>
40+
* resolves with response message on success or rejects with an Exception on error
41+
*/
742
public function query(Query $query);
843
}

0 commit comments

Comments
 (0)