himedia/php-pzq-api

API for PZQ, a persistent store daemon by Mikko Koppanen which uses the ZeroMQ messaging socket library.

v1.0.2 2014-12-10 16:10 UTC

This package is not auto-updated.

Last update: 2024-12-17 07:26:15 UTC


README

PHP API for PZQ, a persistent store daemon by Mikko Koppanen which uses the ZeroMQ messaging socket library.

Latest stable version

This is an implementation from the php-api provided by @mkoppanen.

Installing via Composer

The recommended way to install PHP PZQ API is through Composer.

### Install Composer
curl -sS https://getcomposer.org/installer | php

Next, update your project's composer.json file to include:

{
    "require": {
        "himedia/php-pzq-api": "1.*"
    }
}

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Usage

Consumer usage

$context = new \ZMQContext();
$consumer = new \HIM\PZQ\Consumer($context, "tcp://127.0.0.1:11132");

$ids = array();
for ($i = 0; $i < 10000; $i++) {
    $message = $consumer->consume();
    $consumer->ack($message);
    echo "Consumed {$i}" . PHP_EOL;
}

sleep (5);

Producer usage

$context = new \ZMQContext();
$producer = new \HIM\PZQ\Producer("tcp://127.0.0.1:11131");
$producer->setIgnoreAck(false);

for ($i = 0; $i < 10000; $i++) {
    $message = new \HIM\PZQ\Message();
    $message->setId("id-{$i}");
    $message->setMessage("id-{$i}");
    //echo "Produced id-{$i}" . PHP_EOL;

    $producer->produce($message, 10000);
}

Monitor usage

$m = new \HIM\PZQ\Monitor("ipc:///tmp/pzq-monitor");
var_dump($m->getStats());

Copyrights & licensing

Licensed under the GNU Lesser General Public License v3 (LGPL version 3). See LICENSE file for details.

Change log

See CHANGELOG file for details.

Git branching model

The git branching model used for development is the one described and assisted by twgit tool: https://github.com/Twenga/twgit.