Skip to content

core-haxe/queues-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

queues-core

pluggable queue abstraction

basic usage

queue.onMessage = (item:Int) -> {
    return new Promise((resolve, reject) -> {
        trace("got item", item);
        item++;
        if (item == 31) {
            queue.requeue(item, 1000); // requeue with 1s delay
        }
        resolve(true); // ack
    });
}
queue.start().then(success -> {
    q.enqueue(10);
    q.enqueue(20);
    q.enqueue(30);
    q.enqueue(40);
    q.enqueue(50);
});

simple queue

This is the most basic queue, it will dispatch items seqentually waiting for an ack or nack before dispatching the next item. This is purely an internal implementation for simple things (like making sure http requests are "in order" when dealing with nonces for example)

var queue:IQueue<Int> = QueueFactory.instance.createQueue(QueueFactory.SIMPLE_QUEUE);

non queue

This isnt actually a queue but can be used when an interface for a queue is required (for example its the default in the http request queue). This "queue" simply dispatches items as they come in, there is nothing sequential about this at all. It is not a queue

var queue:IQueue<Int> = QueueFactory.instance.createQueue(QueueFactory.NON_QUEUE);

rabbitmq

var queue:IQueue<Int> = QueueFactory.createDatabase(QueueFactory.RABBITMQ_QUEUE, {
    brokerUrl: "amqp://localhost",
    queueName: "my-http-request-queue"
});

Note: must include queues-rabbitmq for plugin to be auto-registered

About

pluggable queue abstraction

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages