{"id":15828620,"url":"https://github.com/awalterschulze/cloud-example","last_synced_at":"2025-06-25T22:03:47.298Z","repository":{"id":72411052,"uuid":"135061737","full_name":"awalterschulze/cloud-example","owner":"awalterschulze","description":"[Deprecated] Cloud Haskell Example","archived":false,"fork":false,"pushed_at":"2021-08-24T16:37:44.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-12T11:03:09.106Z","etag":null,"topics":["cloud-haskell","example","haskell"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awalterschulze.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-27T16:06:47.000Z","updated_at":"2021-08-24T16:37:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd99f55a-24bd-40f5-b146-06d4736b761d","html_url":"https://github.com/awalterschulze/cloud-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/awalterschulze/cloud-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awalterschulze%2Fcloud-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awalterschulze%2Fcloud-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awalterschulze%2Fcloud-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awalterschulze%2Fcloud-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awalterschulze","download_url":"https://codeload.github.com/awalterschulze/cloud-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awalterschulze%2Fcloud-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261960495,"owners_count":23236571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cloud-haskell","example","haskell"],"created_at":"2024-10-05T10:41:38.810Z","updated_at":"2025-06-25T22:03:47.277Z","avatar_url":"https://github.com/awalterschulze.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloud haskell example\n\nThis example sends a sequence of random numbers between nodes using the [cloud-haskell](http://haskell-distributed.github.io/) framework.\n\n## How\n\nThe master spawns one process on each node, which it initializes with a sorted list of the process ids.\n\nThe first process in the list of process ids elects itself as the leader and starts sending a random number to each of the processes.\nThe random number is used to select the next leader.\nThe current leader knows this and can make sure to first send the random number to all other followers in parallel.\nWhen all followers received the random number the current leader can send the number to the next leader.\nThis way the sequence of random numbers is guaranteed.\n\nWhen the sending time expires, the master sends a shutdown signal to all processes.\nAll processes simply store this channel, but the next leader sends its own shutdown signal to a processes.\nWhen a process has received both shutdown signals, it prints out its result and replies to both channels.\nFinally the leader also prints out its result and replies to the master's channel.\nThis way clean shutdown with empty message queues is achieved.\n\nThe result is a tuple: `(length msgs, sum (imap (\\index msg -\u003e index * msg) msgs))`\n\n## Running\n\n### Requirements\n\nPlease install [stack](https://docs.haskellstack.org/en/stable/README/#how-to-install)\n\n### Testing\n\nTesting allows you to run a full cluster as a unit test:\n\n```\nstack build\nstack test\n```\n\n### Running slave\n\nFirst start up the slaves in the background:\n\n```\nstack exec cloud-example-exe -- --port 4445 \u0026\nstack exec cloud-example-exe -- --port 4446 \u0026\nstack exec cloud-example-exe -- --port 4447 \u0026\n```\n\n### Running master\n\nNext start up the master:\n\n```\nstack exec cloud-example-exe -- --master --send-for 10 --wait-for 30 --with-seed 123 --discover\n```\n\nThis master with tell all slaves to send messages for 10 seconds and then wait for 30 seconds for them to cleanly shutdown.\nThe seed allows the random numbers to be pseudo randomly generated.\nThe discover flags can be used instead of hard coding the nodes in `./app/Main.hs` in the `hardcodedAddrs` function.\n\n## Problems\n\n  - Sleeping with threadDelay is sleeping too long.\n  - Messages always wait for a reply to make sure they arrived at their destination, this could freeze up the whole system.\n  - No restart policies with supervision have been added, which should handle issues when nodes or networks give errors.\n  - Not only random numbers are being sent, but there is also an initial message and shutdown messages.\n  - Require a minimum of at least two slaves.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawalterschulze%2Fcloud-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawalterschulze%2Fcloud-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawalterschulze%2Fcloud-example/lists"}