{"id":19821581,"url":"https://github.com/oestrich/squabble","last_synced_at":"2025-06-26T02:36:51.959Z","repository":{"id":47032610,"uuid":"146376540","full_name":"oestrich/squabble","owner":"oestrich","description":"Simple leader election for Elixir applications","archived":false,"fork":false,"pushed_at":"2021-09-16T13:31:08.000Z","size":22,"stargazers_count":77,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-22T03:05:48.952Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/oestrich.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":"2018-08-28T01:47:34.000Z","updated_at":"2025-06-05T02:24:30.000Z","dependencies_parsed_at":"2022-08-26T10:51:01.709Z","dependency_job_id":null,"html_url":"https://github.com/oestrich/squabble","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/oestrich/squabble","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fsquabble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fsquabble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fsquabble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fsquabble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oestrich","download_url":"https://codeload.github.com/oestrich/squabble/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oestrich%2Fsquabble/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261987741,"owners_count":23240900,"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":["elixir"],"created_at":"2024-11-12T10:29:32.859Z","updated_at":"2025-06-26T02:36:51.934Z","avatar_url":"https://github.com/oestrich.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Squabble\n\nA simple leader election. Pulled from [ExVenture](https://github.com/oestrich/ex_venture).\n\n**Warning:** This has currently only been tested on low traffic production. It works, but may not stand up to _your_ production. I'd love to get it there though!\n\n## What is this doing?\n\nSquabble starts once on each node and uses [Raft](https://raft.github.io/) leadership election amongst all of the nodes. When a leader is selected, callback modules are called on that you supply. This lets you kick off a process _once_ in your cluster anytime cluster state changes.\n\nThis is used in ExVenture to boot the virtual world, for instance.\n\nTwo callbacks are currently provided as seen below, when a new leader is selected and also when a node goes down. ExVenture uses both of these to rebalace the world across the still running cluster.\n\n## Installation\n\nInstall via hex.\n\n```elixir\ndef deps do\n  [\n    {:libcluster, \"~\u003e 3.0\"},\n    {:squabble, \"~\u003e 0.1.0\"},\n  ]\nend\n```\n\nIn order to connect multiple nodes you should also set up [libcluster](https://github.com/bitwalker/libcluster).\n\n## Configuration\n\nConfigure Squabble when you start the worker in your supervision tree. This should go _after_ `libcluster` if you're using that. All nodes should be connected before starting Squabble.\n\n```elixir\nchildren = [\n  {Squabble, [subscriptions: [MyApp.Leader], size: 1]}\n]\n```\n\n## Leader Notifications\n\nSquabble will a call a module on the node when the leader node is selected. This is a behaviour. See a sample below.\n\n```elixir\ndefmodule MyApp.Leader do\n  @behaviour Squabble.Leader\n\n  @impl true\n  def leader_selected(term) do\n  end\n\n  @impl true\n  def node_down() do\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foestrich%2Fsquabble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foestrich%2Fsquabble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foestrich%2Fsquabble/lists"}