{"id":28353088,"url":"https://github.com/gmtprime/exreg","last_synced_at":"2025-10-17T21:01:14.835Z","repository":{"id":48607581,"uuid":"64775843","full_name":"gmtprime/exreg","owner":"gmtprime","description":"A simple process name registry using pg2","archived":false,"fork":false,"pushed_at":"2021-07-18T12:05:08.000Z","size":16,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-20T10:23:29.866Z","etag":null,"topics":["elixir","elixir-lang","registry"],"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/gmtprime.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["alexdesousa"]}},"created_at":"2016-08-02T17:02:00.000Z","updated_at":"2023-09-05T12:35:30.000Z","dependencies_parsed_at":"2022-09-11T02:51:40.134Z","dependency_job_id":null,"html_url":"https://github.com/gmtprime/exreg","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gmtprime/exreg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmtprime%2Fexreg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmtprime%2Fexreg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmtprime%2Fexreg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmtprime%2Fexreg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmtprime","download_url":"https://codeload.github.com/gmtprime/exreg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmtprime%2Fexreg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260987860,"owners_count":23093387,"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","elixir-lang","registry"],"created_at":"2025-05-28T00:10:40.452Z","updated_at":"2025-10-17T21:01:14.826Z","avatar_url":"https://github.com/gmtprime.png","language":"Elixir","funding_links":["https://github.com/sponsors/alexdesousa"],"categories":[],"sub_categories":[],"readme":"# ExReg\n\n[![Build Status](https://travis-ci.org/gmtprime/exreg.svg?branch=master)](https://travis-ci.org/gmtprime/exreg) [![Hex pm](http://img.shields.io/hexpm/v/exreg.svg?style=flat)](https://hex.pm/packages/exreg) [![hex.pm downloads](https://img.shields.io/hexpm/dt/exreg.svg?style=flat)](https://hex.pm/packages/exreg)\n\nA simple process name registry using `:pg`:\n\n- Depends on the built-in Erlang's `:pg` app\n- Can be used with `:via` tuples for naming `GenServers`, `Agents`, etc.\n- Accepts any valid erlang term as process names.\n- Supports several processses with the same name as long as they are not in the\n  same node. Always picks the node closest to the process that called the\n  function.\n\n## Small example\n\nLet's say we define the following `Agent` for keeping a counter:\n\n```elixir\ndefmodule Counter do\n  use Agent\n\n  def start_link(options \\\\ []) do\n    Agent.start_link(fn -\u003e 0 end, options)\n  end\n\n  def increment(counter) do\n    Agent.get_and_update(counter, \u0026{\u00261, \u00261 + 1})\n  end\nend\n```\n\nWe can now start it using `ExReg` as name registry:\n\n```elixir\niex(1)\u003e name = {:via, ExReg, {\"metric\", :my_counter}}\niex(2)\u003e Counter.start_link(name: name)\n{:ok, #PID\u003c0.42.0\u003e}\niex(3)\u003e Counter.increment(name)\n1\niex(4)\u003e Counter.increment(name)\n2\n```\n\n# Distributed systems\n\nIn a distributed environment, there are several things to notice:\n\n- `ExReg` allows several processes to share the same name as long as they are\n  not in the same Erlang node.\n- When starting processes a process locally or sending messages exclusively\n  to a local process:\n\n  * The name should match the type `{:local, term()}` e.g:\n    ```\n    Counter.start_link({:via, ExReg, {:local, {\"metric\", :my_counter}}})\n    ```\n  * The function `ExReg.local({\"metric\", :my_counter})` can also be used to\n    generate the local via tuple.\n\n- When sending messages to a named process, no matter its location:\n\n  * The name should be the term itself or `{:global, term()}` e.g:\n    ```\n    Counter.increment({:via, ExReg, {\"metric\", :my_counter}})\n    ```\n  * The function `ExReg.global({\"metric\", :my_counter})` can also be used to\n    generate the global via tuple.\n\n## Installation\n\nAdd `ExReg` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:exreg, \"~\u003e 1.0\"}]\nend\n```\n\n\u003e Requires OTP 24 or more.\n\n## Author\n\nAlexander de Sousa\n\n## License\n\n`ExReg` is released under the MIT License. See the LICENSE file for further\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmtprime%2Fexreg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmtprime%2Fexreg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmtprime%2Fexreg/lists"}