graze / queue

:postbox: Flexible abstraction for working with queues in PHP.
MIT License
49 stars 10 forks source link

ASync reader #44

Open h-bragg opened 6 years ago

h-bragg commented 6 years ago

Using someones implementation of an event loop and async streams, create an Asynchronous Client

removes the need for acknowledgement handler (a little bit)

interface AsyncMessageHandler {
    public function handle(MessageInterface $message, callable $done) : PromiseInterface
}

class Reader {
    public function asyncRead(AsyncMessageHandler $handler, int $num) {
        // read
        $handler->handle($message, $done)
                ->then($this->acknowledge, $this->reject);
    }
}
h-bragg commented 6 years ago

A start I made a while ago: https://github.com/graze/queue/tree/async-queues