Git Product home page Git Product logo

queue's Introduction

Pekkis Queue

Build Status

A small, opinionated queue abstraction library based on discovered needs. Extracted from Xi Filelib and other assorted projects.

What does it do?

A message consists of a topic and arbitrary data (basic serializable data supported by default, custom serializers can be added). Messages are moved and grooved through a queue. The library extracts a simple, 80/20 like domain for it's method of operation and abstracts away the differences in message queue backends.

Quickstart

<?php

namespace Pekkis\Queue\Example;

use Pekkis\Queue\Adapter\IronMQAdapter;
use Pekkis\Queue\Message;
use Pekkis\Queue\Queue;

require_once (is_file(__DIR__ . '/bootstrap.php')) ? __DIR__ . '/bootstrap.php' : __DIR__ . '/bootstrap.dist.php';

// Create a new IronMQ backed queue
$queue = new Queue(
    new IronMQAdapter(IRONMQ_TOKEN, IRONMQ_PROJECT_ID, 'pekkis-queue-example')
);

// Queues can be emptied.
$queue->purge();

// A message consists of a topic and data. A message instance with an UUID you can use is returned.
$message = $queue->enqueue(
    'pekkis.queue.example',
    array(
        'some' => 'random data'
    )
);

// Dequeue and process a single message
$received = $queue->dequeue();
$data = $received->getData();
var_dump($data);

// Acknowledge the message (you're done with it)
$queue->ack($received);

A better example

For an end-to-end example with IronMQ and a "real life" scenario, see the folder examples.

Also see Xi Filelib (v0.10+) for actual real use case from the real world!

Ideas / wishes? Contact or create a pull request! Cheers!

Supported queues

  • RabbitMQ (via PECL and pure PHP).
  • IronMQ
  • Amazon SQS

Version upgrades

Refer to UPGRADE.md

Todo

SymfonyBridge and Processor sub-packages will be separated to exist in their own packages.

queue's People

Contributors

panunu avatar pekkis avatar

Watchers

 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.