{"id":15285836,"url":"https://github.com/sile/local","last_synced_at":"2025-04-13T02:37:53.571Z","repository":{"id":20933908,"uuid":"24222157","full_name":"sile/local","owner":"sile","description":"A Local Name Registration Facility for Erlang","archived":false,"fork":false,"pushed_at":"2022-03-24T08:38:24.000Z","size":190,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T02:37:19.202Z","etag":null,"topics":["erlang"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/sile.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}},"created_at":"2014-09-19T08:27:20.000Z","updated_at":"2023-07-25T13:53:14.000Z","dependencies_parsed_at":"2022-08-17T16:05:51.435Z","dependency_job_id":null,"html_url":"https://github.com/sile/local","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flocal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flocal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flocal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flocal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/local/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657854,"owners_count":21140843,"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":["erlang"],"created_at":"2024-09-30T15:07:48.253Z","updated_at":"2025-04-13T02:37:53.553Z","avatar_url":"https://github.com/sile.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"local\n=====\n\n[![hex.pm version](https://img.shields.io/hexpm/v/local.svg)](https://hex.pm/packages/local)\n[![Build Status](https://travis-ci.org/sile/local.svg?branch=master)](https://travis-ci.org/sile/local)\n[![Code Coverage](https://codecov.io/gh/sile/local/branch/master/graph/badge.svg)](https://codecov.io/gh/sile/local/branch/master)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA Local Name Registration Facility.\n\nThe library provides the following features:\n- Registration of locally scoped names\n  - `gen_server` (and other OTP behaviours) can use the registration facility through `{via, local, local:name()}` formatted name\n- Can be embedded in another aplication\n\n[Documentation](https://hexdocs.pm/local/)\n\nQuickStart\n----------\n```bash\n# clone\n$ git clone https://github.com/sile/local.git\n$ cd local\n\n# compile\n$ make compile\n\n# run tests\n$ make eunit\n\n# dialyze\n$ make dialyze\n\n# Erlang shell\n$ make start\n1\u003e local:start(sample_name_server).\nok\n```\n\nUsage Example\n-------------\n```erlang\n%% Starts name server\n\u003e ok = local:start_name_server(sample_name_server).\n\u003e local:which_name_servers().\n[sample_name_server]\n\n\n%% Registers process name\n\u003e self().\n\u003c0.42.0\u003e\n\n\u003e local:register_name({sample_name_server, hoge}, self()). % succeeded\nyes\n\n\u003e local:register_name({sample_name_server, hoge}, self()). % failed: name collision\nno\n\n\u003e local:whereis_name({sample_name_server, hoge}).\n\u003c0.42.0\u003e\n\n%% Registered name can be used as gen_server's via name\n\u003e gen_server:cast({via, local, {sample_name_server, hoge}}, hello).\nok\n\n\u003e flush().\nShell got {'$gen_cast',hello}\nok\n\n\n%% Unregisters process name\n\u003e local:unregister_name({sample_name_server, hoge}).\nok\n\n\u003e local:whereis_name({sample_name_server, hoge}).\nundefined\n\n\n%% Stops name server\n\u003e ok = local:stop_name_server(sample_name_server).\n\u003e local:which_name_servers().\n[]\n```\n\nEmbedded Mode\n-------------\n\nLocal can be embedded in your application.\n\n```erlang\n%% Embedding Example\n-module(your_app_sup).\n\n-behaviour(supervisor).\n\n-export([init/1]). % 'supervisor' callback API\n\ninit([]) -\u003e\n    Child1 = local:name_server_child_spec(your_app_name_server_1),\n    Child2 = local:name_server_child_spec(your_app_name_server_2),\n    {ok, { {one_for_one, 5, 10}, [Child1, Child2]} }.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Flocal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Flocal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Flocal/lists"}