Git Product home page Git Product logo

qitsimple's Introduction

Qitsimple (Queue It Simple)

Qitsimple is a queue server and counters server. It runs as a daemon (service). Client applications can connect to qitsimple and push messages (tasks, jobs) to the queue and receive messages from the queue. Connection is via the tcp socket so client applications can reside on the same or on another server to which there is network access. Also you can use named counters. Create, increment, decrement, get and clear value of named counter. Qitsimple it will be useful for the implementation of such micro-services architecture. It implements prioritize messages when the messages with a higher priority "float upwards" in the queue. Qitsimple implements posponed mesages when you can set the time period in seconds after which the only message will appear at the output queue.

How to use:

Client:

<?php
require_once 'MicroQueue.php';
$client = new MicroQueue();
$client->connect("localhost", 5555);

if (!$client->put("queue_one", 5, "queue one - priority 5")) {
  echo "error";
}

$client->put("queue_one", 6, "queue one - priority 6");
$client->put("queue_one", 1000, "queue one - priority 1000");

$client->put("queue_two", 5, "queue two - priority 5");
$client->put("queue_two", 6, "queue two - priority 6");
$client->put("queue_two", 7, "queue two - priority 7");

$client->put_postponed("queue_two", 60, "queue two - 60 seconds later");

$client->put_postponed("queue_two", 5, "queue two - 5 seconds later");

$client->disconnect();

Worker:

<?php
require_once 'MicroQueue.php';
$worker = new MicroQueue();
$worker->connect("localhost", 5555);
echo "Queue 1 length: " . $worker->length("queue_one")."\n";
echo "Queue 2 length: " . $worker->length("queue_two")."\n";
while(true) {
    $result = $worker->get("queue_two");
    if (strpos($result, "::no tasks::") !== 0) {
        echo $result."\n";
    }
    usleep(50000);
}
$client->disconnect();

Get status:

require_once 'MicroQueue.php';

$obj = new MicroQueue();
$obj->connect("localhost", 5555);
$list = $obj->getQuequeList();
foreach ($list as $queue) {
    echo "Queue:" . $queue . " " . $obj->length($queue) . "\n";
    $obj->clean($queue);
}
$obj->disconnect();

Counters:

require_once 'MicroQueue.php';

$obj = new MicroQueue();
$obj->connect("localhost", 5555);

// create and  increment some counters
$obj->inc("counter_1");
$obj->dec("counter_2");

// you can operate with this counters from different processes and even machines
$obj->inc("counter_1");


$list = $obj->getCountersList();
foreach ($list as $queue) {
    echo "Counter:" . $queue . " \t\t" . $obj->getCounter($queue) . "\n";
}

//Reset or clear counter
$obj->clearCounter("counter_2");


$obj->disconnect();

How to compile:

Download project to some directory. In directory:

cmake -DCMAKE_BUILD_TYPE=RELEASE
make

Now run daemon from root:

sudo qitsimple ./config.cfg

Or install it as service and add to autostart at boot:

sudo ./install.sh

qitsimple's People

Contributors

wagok avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.