接口原型

0x01、消息中间件

interface BrokerInterface
{
    /**
     * @brief    __construct    
     *
     * @param    array  $config
     *
     * @return   null
     */
    public function __construct($config = array());

    /**
     * @brief    close connection
     *
     * @return   boolean
     */
    public function close();

    /**
     * @brief    push data into queue
     *
     * @param    string  $text
     *
     * @return bool|string 
     */
    public function push($queue_name = '', $text = '');

    /**
     * @brief    pop data from queue
     *
     * @param    string  $queue_name
     * @param    string  $wait
     *
     * @return   boolean|string
     */
    public function pop($queue_name, $wait = false);

    /**
     * @brief    message acknowledge
     *
     * @param    string  $queue_name
     * @param    int     $delivery_tag
     *
     * @return   boolean
     */
    public function acknowledge($queue_name, $delivery_tag);

    /**
     * @brief    purge queue 
     *
     * @param    string  $queue_name
     *
     * @return   boolean
     */
    public function purge($queue_name);
}

0x02、去重过滤器中间件

Interface DropDuplicateInterface
{
    /**
     * @brief    add element to bit array, called collections.
     *
     * @param    string  $element
     *
     * @return   void
     */
    public function add($element);

    /**
     * @brief    check whether element exists bit array, called collections.   
     *
     * @param    string  $element
     *
     * @return   boolean
     */
    public function has($element);
}

0x03、http客户端中间件

interface HttpClientInterface
{
    /**
     * create and send an HTTP request
     *
     * @param string              $method  HTTP method.
     * @param string|UriInterface $uri     URI object or string.
     * @param array               $options Request options to apply.
     *
     * @return ResponseInterface
     * @throws GuzzleException
     */
    public function request($method, $uri, array $options = []);

    /**
     * get response status code
     *
     * @return  int
     */
    public function getResponseStatusCode();

    /**
     * get response status message
     *
     * @return  string
     */
    public function getResponseStatusMessage();

    /**
     * get response body
     *
     * @return  string
     */
    public function getResponseBody();
}

0x04、锁中间件

interface LockInterface 
{
    /**
     * @brief    lock   
     *
     * @param    string  $key
     *
     * @return   int
     */
    public function lock($key);

    /**
     * @brief    unlock     
     *
     * @param    string  $key
     * @param    int     $timeout
     *
     * @return   boolean
     */
    public function unlock($key, $timeout = 0);
}

0x05、插件接口

interface PluginInterface
{
    /**
     * @brief    install plugin  
     *
     * @param    object          $phpcreeper
     * @param    string | array  $plugins
     * @param    mixed           $args
     *
     * @return   object
     */
    static public function install(PHPCreeper $phpcreeper, ...$args);
}

results matching ""

    No results matching ""