ServiceClientInterface.php
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace GuzzleHttp\Command;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Command\Exception\CommandException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Promise\PromiseInterface;
/**
* Web service client interface.
*/
interface ServiceClientInterface
{
/**
* Create a command for an operation name.
*
* Special keys may be set on the command to control how it behaves.
* Implementations SHOULD be able to utilize the following keys or throw
* an exception if unable.
*
* @param string $name Name of the operation to use in the command
* @param array $args Arguments to pass to the command
*
* @return CommandInterface
*
* @throws \InvalidArgumentException if no command can be found by name
*/
public function getCommand($name, array $args = []);
/**
* Execute a single command.
*
* @param CommandInterface $command Command to execute
*
* @return ResultInterface The result of the executed command
*
* @throws CommandException
*/
public function execute(CommandInterface $command);
/**
* Execute a single command asynchronously
*
* @param CommandInterface $command Command to execute
*
* @return PromiseInterface A Promise that resolves to a Result.
*/
public function executeAsync(CommandInterface $command);
/**
* Executes multiple commands concurrently using a fixed pool size.
*
* @param array|\Iterator $commands Array or iterator that contains
* CommandInterface objects to execute with the client.
* @param array $options Associative array of options to apply.
* - concurrency: (int) Max number of commands to execute concurrently.
* - fulfilled: (callable) Function to invoke when a command completes.
* - rejected: (callable) Function to invoke when a command fails.
*
* @return array
*
* @see GuzzleHttp\Command\ServiceClientInterface::createPool for options.
*/
public function executeAll($commands, array $options = []);
/**
* Executes multiple commands concurrently and asynchronously using a
* fixed pool size.
*
* @param array|\Iterator $commands Array or iterator that contains
* CommandInterface objects to execute with the client.
* @param array $options Associative array of options to apply.
* - concurrency: (int) Max number of commands to execute concurrently.
* - fulfilled: (callable) Function to invoke when a command completes.
* - rejected: (callable) Function to invoke when a command fails.
*
* @return PromiseInterface
*
* @see GuzzleHttp\Command\ServiceClientInterface::createPool for options.
*/
public function executeAllAsync($commands, array $options = []);
/**
* Get the HTTP client used to send requests for the web service client
*
* @return ClientInterface
*/
public function getHttpClient();
/**
* Get the HandlerStack which can be used to add middleware to the client.
*
* @return HandlerStack
*/
public function getHandlerStack();
}