{"id":21038716,"url":"https://github.com/ceribe/lyra","last_synced_at":"2026-05-21T02:05:49.158Z","repository":{"id":180367326,"uuid":"564912468","full_name":"ceribe/lyra","owner":"ceribe","description":"Library which helps with implementation of distributed algorithms","archived":false,"fork":false,"pushed_at":"2023-07-11T09:21:42.000Z","size":244,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-02T10:54:58.216Z","etag":null,"topics":["distributed-systems","kotlin","poznan-university-of-technology","tcp","websocket","zeromq"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceribe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-11T19:56:14.000Z","updated_at":"2023-07-11T09:15:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c5c6c50-35a4-47a2-bc80-eefbecbed00b","html_url":"https://github.com/ceribe/lyra","commit_stats":null,"previous_names":["ceribe/lyra"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ceribe/lyra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceribe%2Flyra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceribe%2Flyra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceribe%2Flyra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceribe%2Flyra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceribe","download_url":"https://codeload.github.com/ceribe/lyra/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceribe%2Flyra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33284961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-20T15:12:43.734Z","status":"online","status_checked_at":"2026-05-21T02:00:07.181Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["distributed-systems","kotlin","poznan-university-of-technology","tcp","websocket","zeromq"],"created_at":"2024-11-19T13:34:22.942Z","updated_at":"2026-05-21T02:05:49.128Z","avatar_url":"https://github.com/ceribe.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lyra: Distributed Algorithms Platform\n\nLyra is a library that helps with implementation of distributed algorithms. Instead of the typical approach the whole algorithm is programmed as a set of responses to incoming messages. Serialization, synchronization, message passing are abstracted away so the only thing that end-user (programmer) has to do is implement the algorithm.\n\nIn the current state the project is finished. However documentation and tests aren't finished. I might do it at some point. \n\n# How to use\n\n### 1. Add lyra module to your project\nEither copy the files or link the module.\n\n### 2. Create a class which implements NodeState\n\nAn instance of this class will be used to store local state of a node\n\n```kotlin\nclass ExampleState(nodeNumber: Int): NodeState(nodeNumber) {\n    var numberOfConfirmations = 0\n    var numberOfRequests = 0\n}\n```\n\n### 3. Implement the algorithm\n\nThe algorithm implemented below works like this:\n- Each node sends a request message to each node\n- After getting a request from each node, each node sends a response message back\n- After getting a response from each node, each node does \"some work\"\n\n```kotlin\n@kotlinx.serialization.Serializable\nclass InitMessage : Message\u003cExampleState\u003e() {\n    override suspend fun react() {\n        sendToAll(message = RequestMessage())\n    }\n}\n\n@kotlinx.serialization.Serializable\nclass RequestMessage : Message\u003cExampleState\u003e() {\n    override suspend fun react() {\n        state.numberOfRequests++\n        waitFor { state.numberOfRequests == state.numberOfNodes }\n        sendTo(\n            message = ResponseMessage(),\n            recipient = sender\n        )\n    }\n}\n\n@kotlinx.serialization.Serializable\nclass ResponseMessage : Message\u003cExampleState\u003e() {\n    override suspend fun react() {\n        state.numberOfConfirmations++\n        if (state.numberOfConfirmations \u003c state.numberOfNodes) {\n            return\n        }\n        doSomeWork()\n    }\n}\n```\n\n- sendToAll - Sends given message to all nodes in the system (including the node node that's sending the message)\n- sendTo - Sands given message to node with given index\n- waitFor - Suspends the execution of the \"react\" function until the given condition is met\n\n### 5. Create a Lyra instance and run it\n\n```kotlin\nval lyra = Lyra(\n    messageSystem = SocketMessageSystem(...),\n    initMessage = InitMessage(),\n    serializationType = SerializationType.JSON,\n    nodeState = ExampleState(nodeNumber),\n    synchronizeNodes = { Thread.sleep(30000) }\n) {\n    registerMessageType\u003cInitMessage\u003e()\n    registerMessageType\u003cRequestMessage\u003e()\n    registerMessageType\u003cResponseMessage\u003e()\n}\nlyra.run()\n```\n\n- messageSystem - Any class that implements \"MessageSystem\" interface. This component is used to send messages between nodes\n- initMessage - Message that node will send to itself after initalization. If is null then no message is send\n- serializationType - Either JSON or ProtoBuf\n- nodeState - Initial state that the node will use\n- synchronizeNodes - Function that should make it so all nodes are initialized before any message is send so no messages are lost\n\nIn { } all used message types have to be registered (in same order an all nodes).\nAn instance of Lyra class has to be created and run on all nodes in the system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceribe%2Flyra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceribe%2Flyra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceribe%2Flyra/lists"}