{"id":15056380,"url":"https://github.com/ostinelli/syn","last_synced_at":"2025-05-15T01:08:16.743Z","repository":{"id":33538132,"uuid":"37184262","full_name":"ostinelli/syn","owner":"ostinelli","description":"A scalable global Process Registry and Process Group manager for Erlang and Elixir.","archived":false,"fork":false,"pushed_at":"2024-08-23T17:15:59.000Z","size":1603,"stargazers_count":651,"open_issues_count":4,"forks_count":78,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-05-14T15:05:56.047Z","etag":null,"topics":["cluster","conflict-resolution","elixir","elixir-lang","erlang","process-group","process-registry","pubsub"],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/ostinelli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2015-06-10T08:14:00.000Z","updated_at":"2025-04-25T07:10:32.000Z","dependencies_parsed_at":"2024-06-18T15:18:19.459Z","dependency_job_id":"270fa788-a878-463d-a1c1-34161d9b5bd8","html_url":"https://github.com/ostinelli/syn","commit_stats":{"total_commits":559,"total_committers":14,"mean_commits":39.92857142857143,"dds":0.03220035778175312,"last_synced_commit":"4b5fbc17e8008af2780af61fbf6966c15036741e"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostinelli%2Fsyn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostinelli%2Fsyn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostinelli%2Fsyn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostinelli%2Fsyn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ostinelli","download_url":"https://codeload.github.com/ostinelli/syn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254042,"owners_count":22039792,"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":["cluster","conflict-resolution","elixir","elixir-lang","erlang","process-group","process-registry","pubsub"],"created_at":"2024-09-24T21:50:22.512Z","updated_at":"2025-05-15T01:08:11.728Z","avatar_url":"https://github.com/ostinelli.png","language":"Erlang","readme":"![CI](https://github.com/ostinelli/syn/actions/workflows/ci.yml/badge.svg) [![Hex pm](https://img.shields.io/hexpm/v/syn.svg)](https://hex.pm/packages/syn)\n\n# Syn\n**Syn** (short for _synonym_) is a scalable global Process Registry and Process Group manager for Erlang and Elixir,\nable to automatically manage dynamic clusters (addition / removal of nodes) and to recover from net splits.\n\nSyn is a replacement for Erlang/OTP\n[global](https://www.erlang.org/doc/man/global.html)'s registry and\n[pg](https://www.erlang.org/doc/man/pg.html) modules. The main differences with these OTP's implementations are:\n\n* OTP's `global` module chooses Consistency over Availability, therefore it can become difficult to scale\n  when registration rates are elevated and the cluster becomes larger. If eventual consistency is acceptable in your\n  case, Syn can considerably increase the registry's performance.\n* Syn allows to attach metadata to every process, which also gets synchronized across the cluster.\n* Syn implements [cluster-wide callbacks](syn_event_handler.html) on the main events, which are also properly triggered\n  after net splits.\n\n[[Documentation](https://hexdocs.pm/syn/)]\n\n## Introduction\n\n### What is a Process Registry?\nA global Process Registry allows registering a process on all the nodes of a cluster with a single Key.\nConsider this the process equivalent of a DNS server: in the same way you can retrieve an IP address from a domain name,\nyou can retrieve a process from its Key.\n\nTypical Use Case: registering on a system a process that handles a physical device (using its serial number).\n\n### What is a Process Group?\nA global Process Group is a named group which contains many processes, possibly running on different nodes.\nWith the group Name, you can retrieve on any cluster node the list of these processes, or publish a message to all of them.\nThis mechanism allows for Publish / Subscribe patterns.\n\nTypical Use Case: a chatroom.\n\n### What is Syn?\nSyn is a Process Registry and Process Group manager that has the following features:\n\n* Global Process Registry (i.e. a process is uniquely identified with a Key across all the nodes of a cluster).\n* Global Process Group manager (i.e. a group is uniquely identified with a Name across all the nodes of a cluster).\n* Any term can be used as Key and Name.\n* PubSub mechanism: messages can be published to all members of a Process Group (_globally_ on all the cluster or _locally_ on a single node). \n* Subclusters by using Scopes allows great scalability.\n* Dynamically sized clusters (addition / removal of nodes is handled automatically).\n* Net Splits automatic resolution.\n* Fast writes.\n* Configurable callbacks.\n* Processes are automatically monitored and removed from the Process Registry and Process Groups if they die.\n\n## Notes\nIn any distributed system you are faced with a consistency challenge, which is often resolved by having one master arbiter\nperforming all write operations (chosen with a mechanism of [leader election](http://en.wikipedia.org/wiki/Leader_election)),\nor through [atomic transactions](http://en.wikipedia.org/wiki/Atomicity_(database_systems)).\n\nSyn was born for applications of the [IoT](http://en.wikipedia.org/wiki/Internet_of_Things) field. In this context,\nKeys used to identify a process are often the physical object's unique identifier (for instance, its serial or MAC address),\nand are therefore already defined and unique _before_ hitting the system. The consistency challenge is less of a problem in this case,\nsince the likelihood of concurrent incoming requests that would register processes with the same Key is extremely low and, in most cases, acceptable.\n\nIn addition, write speeds were a determining factor in the architecture of Syn.\n\nTherefore, Availability has been chosen over Consistency and Syn implements\n[strong eventual consistency](http://en.wikipedia.org/wiki/Eventual_consistency).\n\n## Installation\n\n#### Elixir\nAdd it to your deps:\n\n```elixir\ndefp deps do\n  [{:syn, \"~\u003e 3.3\"}]\nend\n```\n\n#### Erlang\nIf you're using [rebar3](https://github.com/erlang/rebar3), add `syn` as a dependency in your project's `rebar.config` file:\n\n```erlang\n{deps, [\n  {syn, {git, \"git://github.com/ostinelli/syn.git\", {tag, \"3.3.0\"}}}\n]}.\n```\nOr, if you're using [Hex.pm](https://hex.pm/) as package manager (with the [rebar3_hex](https://github.com/hexpm/rebar3_hex) plugin):\n\n```erlang\n{deps, [\n  {syn, \"3.3.0\"}\n]}.\n```\n\nEnsure that `syn` is started with your application, for example by adding it in your `.app` file to the list of `applications`:\n\n```erlang\n{application, my_app, [\n    %% ...\n    {applications, [\n        kernel,\n        stdlib,\n        sasl,\n        syn,\n        %% ...\n    ]},\n    %% ...\n]}.\n```\n\n## Quickstart\n\n### Registry\n\n#### Elixir\n\n```elixir\niex\u003e :syn.add_node_to_scopes([:users])\n:ok\niex\u003e pid = self()\n#PID\u003c0.105.0\u003e\niex\u003e :syn.register(:users, \"hedy\", pid)\n:ok\niex\u003e :syn.lookup(:users, \"hedy\")\n{#PID\u003c0.105.0\u003e,:undefined}\niex\u003e :syn.register(:users, \"hedy\", pid, [city: \"Milan\"])\n:ok\niex\u003e :syn.lookup(:users, \"hedy\")\n{#PID\u003c0.105.0\u003e,[city: \"Milan\"]}\niex\u003e :syn.registry_count(:users)\n1\n```\n\n#### Erlang\n\n```erlang\n1\u003e syn:add_node_to_scopes([users]).\nok\n2\u003e Pid = self().\n\u003c0.93.0\u003e\n3\u003e syn:register(users, \"hedy\", Pid).\nok\n4\u003e syn:lookup(users, \"hedy\").\n{\u003c0.93.0\u003e,undefined}\n5\u003e syn:register(users, \"hedy\", Pid, [{city, \"Milan\"}]).\nok\n6\u003e syn:lookup(users, \"hedy\").\n{\u003c0.93.0\u003e,[{city, \"Milan\"}]}\n7\u003e syn:registry_count(users).\n1\n```\n\n### Process Groups\n\n#### Elixir\n\n```elixir\niex\u003e :syn.add_node_to_scopes([:users])\n:ok\niex\u003e pid = self()\n#PID\u003c0.88.0\u003e\niex\u003e :syn.join(:users, {:italy, :lombardy}, pid)\n:ok\niex\u003e :syn.members(:users, {:italy, :lombardy})\n[{#PID\u003c0.88.0\u003e,:undefined}]\niex\u003e :syn.is_member(:users, {:italy, :lombardy}, pid)\ntrue\niex\u003e :syn.publish(:users, {:italy, :lombardy}, \"hello lombardy!\")\n{:ok,1}\niex\u003e flush()\nShell got \"hello lombardy!\"\nok\n```\n\n#### Erlang\n\n```erlang\n1\u003e syn:add_node_to_scopes([users]).\nok\n2\u003e Pid = self().\n\u003c0.88.0\u003e\n3\u003e syn:join(users, {italy, lombardy}, Pid).\nok\n4\u003e syn:members(users, {italy, lombardy}).\n[{\u003c0.88.0\u003e,undefined}]\n5\u003e syn:is_member(users, {italy, lombardy}, Pid).\ntrue\n6\u003e syn:publish(users, {italy, lombardy}, \"hello lombardy!\").\n{ok,1}\n7\u003e flush().\nShell got \"hello lombardy!\"\nok\n```\n\n## Contributing\nSo you want to contribute? That's great! Please follow the guidelines below. It will make it easier to get merged in.\n\nBefore implementing a new feature, please submit a ticket to discuss what you intend to do. Your feature might\nalready be in the works, or an alternative implementation might have already been discussed.\n\nDo not commit to master in your fork. Provide a clean branch without merge commits. Every pull request should have\nits own topic branch. In this way, every additional adjustments to the original pull request might be done easily,\nand squashed with `git rebase -i`. The updated branch will be visible in the same pull request, so there will be no need\nto open new pull requests when there are changes to be applied.\n\nEnsure that proper testing is included. To run Syn tests you simply have to be in the project's root directory and run:\n\n```bash\n$ make test\n```\n\n## License\n\nCopyright (c) 2015-2022 Roberto Ostinelli and Neato Robotics, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fostinelli%2Fsyn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fostinelli%2Fsyn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fostinelli%2Fsyn/lists"}