{"id":21194470,"url":"https://github.com/cspray/amp-delivery-service","last_synced_at":"2026-04-14T17:32:15.905Z","repository":{"id":143070777,"uuid":"42028835","full_name":"cspray/amp-delivery-service","owner":"cspray","description":"An implementation of DeliveryService using Amp's event reactor","archived":false,"fork":false,"pushed_at":"2015-09-24T01:00:31.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T20:20:31.315Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cspray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-07T03:13:12.000Z","updated_at":"2017-02-26T00:01:23.000Z","dependencies_parsed_at":"2023-03-16T10:25:41.817Z","dependency_job_id":null,"html_url":"https://github.com/cspray/amp-delivery-service","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cspray/amp-delivery-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Famp-delivery-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Famp-delivery-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Famp-delivery-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Famp-delivery-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cspray","download_url":"https://codeload.github.com/cspray/amp-delivery-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Famp-delivery-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31808505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T11:13:53.975Z","status":"ssl_error","status_checked_at":"2026-04-14T11:13:53.299Z","response_time":153,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T19:22:26.071Z","updated_at":"2026-04-14T17:32:15.882Z","avatar_url":"https://github.com/cspray.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeliveryService\n\nAn implementation of [DeliveryService](https://github.com/cspray/delivery-service) using the [Amp]() event loop reactor. \nIt is expected before uing this library you understand how these 2 dependencies operate.\n\n## DeliveryService Hello World\n\nHere we take a look at the official Hello World example for DeliveryService implementations. This is \nthe bare minimum \n\n```\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse Cspray\\DeliveryService;\nuse Cspray\\DeliveryService\\Amp\\ReceiptPromisorFactory;\nuse Cspray\\DeliveryService\\Amp\\Mediator;\n\n$reactor = new Amp\\NativeReactor();\n$promisorFactory = new ReceiptPromisorFactory();\n$transmitter = new DeliveryService\\Transmitter($promisorFactory);\n$receiver = new DeliveryService\\Receiver();\n$mediator = new Mediator($reactor, $transmitter, $receiver);\n\n$message = new DeliveryService\\GenericMessage('foobar', 'the payload');\n$messagePromise = $transmitter-\u003esend($message);\n$messagePromise-\u003edelivered(function() {\n    echo \"after listeners\\n\";\n});\n\n$receiver-\u003elisten('foobar', function(DeliveryService\\Message $message) {\n    echo \"{$message-\u003egetType()}\\n\";\n    echo \"{$message-\u003egetPayload()}\\n\";\n});\n\n$mediator-\u003estartSendingMessages();\n\n$reactor-\u003etick();\n$reactor-\u003etick();\n\n//--EXPECT--\nfoobar\nthe payload\nafter listeners\n\n```\n\n## Two-tick delivery\n\nThe 2 ticks in the above example is not a mistake. We intentionally invoke message listeners\nthe tick *after* it gets removed from the queue. This is done so that listeners run within \nthe event loop and are invoked concurrently.\n\n\n```\n--------|------------------|------------------|---------------|---\n dequeue message     invoke listeners   invoke listeners      .\n queue listeners     dequeue message    dequeue message       .\n                     queue listeners    queue listeners       .\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcspray%2Famp-delivery-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcspray%2Famp-delivery-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcspray%2Famp-delivery-service/lists"}