{"id":21194468,"url":"https://github.com/cspray/delivery-service","last_synced_at":"2026-04-25T08:32:58.616Z","repository":{"id":143070849,"uuid":"41968901","full_name":"cspray/delivery-service","owner":"cspray","description":"Abstraction to allow sending intra-process messages within an asynchronous event loop.","archived":false,"fork":false,"pushed_at":"2015-09-24T00:54:14.000Z","size":200,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-02T23:13:43.964Z","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":"CHANGELOG.md","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-05T17:03:41.000Z","updated_at":"2017-07-19T14:37:28.000Z","dependencies_parsed_at":"2023-03-16T10:25:41.551Z","dependency_job_id":null,"html_url":"https://github.com/cspray/delivery-service","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cspray/delivery-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdelivery-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdelivery-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdelivery-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdelivery-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cspray","download_url":"https://codeload.github.com/cspray/delivery-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdelivery-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32255216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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:24.254Z","updated_at":"2026-04-25T08:32:58.587Z","avatar_url":"https://github.com/cspray.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeliveryService\n\nA library to allow transmitting and receiving messages within an asynchronous event loop. \nIncludes a receipt that all listeners for a given messgae have read it.\n\nThis library primarily holds the interfaces designed to provide the discussed functionality \nand generic implementations that are not dependent on any particular event reactor. For \nfunctional implementations of these interfaces please check out:\n\n- [`cspray/amp-delivery-service`](https://github.com/cspray/amp-delivery-service)\n\n**This library requires PHP7! Because of this it will not be production ready until PHP7 is.**\n\n## Overview\n\nHere we talk about the interfaces that provide the messaging abstraction layer we place on \ntop of your favorite reactor. It is assumed from this point forward that you have a high-level \nunderstanding of event loops, promises, and promisors. \n \n### `Message`\n\nRepresents a type and a set of data that can be transmitted and received. In other words, a message. \nThe payload of the message can be whatever is appropriate for your domain.\n \n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface Message {\n    \n    public function getType() : string;\n    \n    public function getPayload();\n    \n}\n```\n\n### `Receipt`\n\nEvery time you send a message you get a Receipt. This is a promise that will invoke any callbacks \nwhen the Message has been received by *everybody* that's supposed to receive it. The callback will \nbe invoked regardless of whether listeners threw an exception; check out the DeliveryResults interface \nfor more information.\n\n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface Receipt {\n\n    /**\n     * The $callback should match the below signature:\n     *\n     * function(DeliveryResults $results, Message $message) {\n     *\n     * }\n     */\n    public function delivered(callable $callback);\n    \n}\n```\n\n### `DeliveryResults`\n\nRepresents the results of a Message having been delivered to all of its recipients. \nAn implementation of this interface gets passed to all callbacks attached to a \nReceipt.\n\n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface DeliveryResults {\n\n    public function getNumberListeners() : int;\n    \n    public function getSuccessfulResults() : array;\n    \n    public function getFailureResults() : array;\n\n    // The arrays returned from both successful and failed should match the following format\n    // [$listenerId =\u003e $listenerReturnOrThrownException]\n\n}}\n```\n\n### `Receiver`\n\nYour code needs some way to receive messages; you accomplish this by adding a listener \nfor a specific type of Message to a Receiver.\n\n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface Receiver {\n    \n    // The string returned should be a unique identifier for the specific type and callable passed\n    public function listen(string $messageType, callable $callback) : string;\n    \n    public function removeListener(string $listenerId);\n    \n    public function getListenersForType(string $messageType);\n    \n}\n```\n\n### `Transmitter`\n\nIf you expect to receive a message you need to send one first! The Transmitter interface is designed \nto do exactly that. Specifically we expect implementations to add Messages to a MessageQueue implementation, \nwe'll get to that one below.\n\n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface Transmitter {\n\n    public function send(Message $message) : Receipt;\n    \n    public function getMessageQueue() : MesageQueue;\n\n}\n```\n\n### `MessageQueue`\n\nA first-in, first-out queue that holds Messages that are awaiting delivery. When a message is delivered it is \nremoved from the queue.\n\n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface MessageQueue {\n\n    public function enqueue(MessageReceiptPromisor $messageReceiptPromisor);\n    \n    public function dequeue() : MessageReceiptPromisor;\n    \n    public function isEmpty() : bool;\n    \n    public function hasMessages() : bool;\n\n}\n```\n\n### `Mediator`\n\nFinally the interface that brings everything together. It coordinates with the event reactor of your \nchoice, as well as a transmitter and receiver to actually dispatch thes Messages.\n\n```\n\u003c?php\n\nnamespace Cspray\\DeliveryService;\n\ninterface Mediator {\n\n    public function startSendingMessages();\n    \n    public function stopSendingMessages();\n\n}\n```\n\nFor more information check out the implementation libraries that are listed above.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcspray%2Fdelivery-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcspray%2Fdelivery-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcspray%2Fdelivery-service/lists"}