Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cspray/amp-delivery-service
An implementation of DeliveryService using Amp's event reactor
https://github.com/cspray/amp-delivery-service
Last synced: about 1 month ago
JSON representation
An implementation of DeliveryService using Amp's event reactor
- Host: GitHub
- URL: https://github.com/cspray/amp-delivery-service
- Owner: cspray
- License: mit
- Created: 2015-09-07T03:13:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-24T01:00:31.000Z (about 9 years ago)
- Last Synced: 2023-03-16T10:20:27.167Z (almost 2 years ago)
- Language: PHP
- Size: 184 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeliveryService
An implementation of [DeliveryService](https://github.com/cspray/delivery-service) using the [Amp]() event loop reactor.
It is expected before uing this library you understand how these 2 dependencies operate.## DeliveryService Hello World
Here we take a look at the official Hello World example for DeliveryService implementations. This is
the bare minimum```
send($message);
$messagePromise->delivered(function() {
echo "after listeners\n";
});$receiver->listen('foobar', function(DeliveryService\Message $message) {
echo "{$message->getType()}\n";
echo "{$message->getPayload()}\n";
});$mediator->startSendingMessages();
$reactor->tick();
$reactor->tick();//--EXPECT--
foobar
the payload
after listeners```
## Two-tick delivery
The 2 ticks in the above example is not a mistake. We intentionally invoke message listeners
the tick *after* it gets removed from the queue. This is done so that listeners run within
the event loop and are invoked concurrently.```
--------|------------------|------------------|---------------|---
dequeue message invoke listeners invoke listeners .
queue listeners dequeue message dequeue message .
queue listeners queue listeners .
```