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