Adapter.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. * LICENSE
  4. *
  5. * This source file is subject to the new BSD license that is bundled
  6. * with this package in the file LICENSE.txt.
  7. * It is also available through the world-wide-web at this URL:
  8. * http://framework.zend.com/license/new-bsd
  9. * If you did not receive a copy of the license and are unable to
  10. * obtain it through the world-wide-web, please send an email
  11. * to license@zend.com so we can send you a copy immediately.
  12. *
  13. * @category Zend
  14. * @package Zend_Cloud
  15. * @subpackage QueueService
  16. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  17. * @license http://framework.zend.com/license/new-bsd New BSD License
  18. */
  19. /**
  20. * Common interface for queue services in the cloud. This interface supports
  21. * most queue services and provides some flexibility for vendor-specific
  22. * features and requirements via an optional $options array in each method
  23. * signature. Classes implementing this interface should implement URI
  24. * construction for queues from the parameters given in each method and the
  25. * account data passed in to the constructor. Classes implementing this
  26. * interface are also responsible for security; access control isn't currently
  27. * supported in this interface, although we are considering access control
  28. * support in future versions of the interface.
  29. *
  30. * @category Zend
  31. * @package Zend_Cloud
  32. * @subpackage QueueService
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. interface Zend_Cloud_QueueService_Adapter
  37. {
  38. /** Ctor HTTP adapter option */
  39. const HTTP_ADAPTER = 'http_adapter';
  40. /** Message visibility timeout option */
  41. const VISIBILITY_TIMEOUT = 'visibility_timeout';
  42. /** Default visibility timeout */
  43. const DEFAULT_TIMEOUT = 30;
  44. /**
  45. * Create a queue. Returns the ID of the created queue (typically the URL).
  46. * It may take some time to create the queue. Check your vendor's
  47. * documentation for details.
  48. *
  49. * Name constraints: Maximum 80 characters
  50. * Only alphanumeric characters, hyphens (-), and underscores (_)
  51. *
  52. * @param string $name
  53. * @param array $options
  54. * @return string Queue ID (typically URL)
  55. */
  56. public function createQueue($name, $options = null);
  57. /**
  58. * Delete a queue. All messages in the queue will also be deleted.
  59. *
  60. * @param string $queueId
  61. * @param array $options
  62. * @return boolean true if successful, false otherwise
  63. */
  64. public function deleteQueue($queueId, $options = null);
  65. /**
  66. * List all queues.
  67. *
  68. * @param array $options
  69. * @return array Queue IDs
  70. */
  71. public function listQueues($options = null);
  72. /**
  73. * Get a key/value array of metadata for the given queue.
  74. *
  75. * @param string $queueId
  76. * @param array $options
  77. * @return array
  78. */
  79. public function fetchQueueMetadata($queueId, $options = null);
  80. /**
  81. * Store a key/value array of metadata for the specified queue.
  82. * WARNING: This operation overwrites any metadata that is located at
  83. * $destinationPath. Some adapters may not support this method.
  84. *
  85. * @param string $queueId
  86. * @param array $metadata
  87. * @param array $options
  88. * @return void
  89. */
  90. public function storeQueueMetadata($queueId, $metadata, $options = null);
  91. /**
  92. * Send a message to the specified queue.
  93. *
  94. * @param string $queueId
  95. * @param string $message
  96. * @param array $options
  97. * @return string Message ID
  98. */
  99. public function sendMessage($queueId, $message, $options = null);
  100. /**
  101. * Recieve at most $max messages from the specified queue and return the
  102. * message IDs for messages recieved.
  103. *
  104. * @param string $queueId
  105. * @param int $max
  106. * @param array $options
  107. * @return array[Zend_Cloud_QueueService_Message] Array of messages
  108. */
  109. public function receiveMessages($queueId, $max = 1, $options = null);
  110. /**
  111. * Peek at the messages from the specified queue without removing them.
  112. *
  113. * @param string $queueId
  114. * @param int $num How many messages
  115. * @param array $options
  116. * @return array[Zend_Cloud_QueueService_Message]
  117. */
  118. public function peekMessages($queueId, $num = 1, $options = null);
  119. /**
  120. * Delete the specified message from the specified queue.
  121. *
  122. * @param string $queueId
  123. * @param Zend_Cloud_QueueService_Message $message Message to delete
  124. * @param array $options
  125. * @return void
  126. *
  127. */
  128. public function deleteMessage($queueId, $message, $options = null);
  129. /**
  130. * Get the concrete adapter.
  131. */
  132. public function getClient();
  133. }