ServiceClientInterface.php 3.1 KB

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