{"_id":"58f5e5e94c413f19007a277c","category":{"_id":"58f5e5c2616bbb1b00d54c15","project":"5612c2a00fbdb60d00e4c7d1","version":"5612c2a00fbdb60d00e4c7d4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-04-18T10:09:06.400Z","from_sync":false,"order":2,"slug":"lasp-pg","title":"Lasp PG"},"parentDoc":null,"__v":0,"user":"5612c290c0731b0d00625078","project":"5612c2a00fbdb60d00e4c7d1","version":{"_id":"5612c2a00fbdb60d00e4c7d4","__v":7,"project":"5612c2a00fbdb60d00e4c7d1","createdAt":"2015-10-05T18:34:08.611Z","releaseDate":"2015-10-05T18:34:08.611Z","categories":["5612c2a10fbdb60d00e4c7d5","58e6b64bc397de1b00173c09","58e6b68eb1eece19008b81fe","58e6b6d185ec873100be9734","58f5e5c2616bbb1b00d54c15","58f5eaa74c413f19007a2858","58f767a79c723f19004e1ca9"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.0.1","version":"0.0.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-04-18T10:09:45.339Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Lasp PG is an eventually consistent, process registry for Erlang, the spiritual successor to [Riak PG](https://github.com/cmeiklejohn/riak_pg).  Lasp PG is similar to facilities like `global` and `pg2`, but with many of the convergence anomalies removed through the use of CRDTs.  Lasp PG completely bypasses distributed Erlang, and does full replication of the groups to all nodes in the cluster.\n\nIt's based on CRDTs, and uses Lasp's underlying highly-available key-value store and membership layer ensuring high-scalability and fault-tolerance.\n[block:api-header]\n{\n  \"title\": \"Building\"\n}\n[/block]\nSimple, clone it from GitHub and build!\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ git clone git:::at:::github.com:lasp-lang/lasp_pg.git\\n$ cd lasp_pg\\n$ make\\n$ make check\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Clustering Nodes\"\n}\n[/block]\nIn order to join Lasp PG to other nodes in the system, you can use the clustering API directly to specify the name of a remote node.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"> lasp_peer_service:join({Name, IP, Port}).\",\n      \"language\": \"erlang\"\n    }\n  ]\n}\n[/block]\nAs Lasp PG relies on our Partisan library, to retrieve your node's name, IP address, and port, you can use the `myself` command provided by Partisan.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"> partisan_peer_service_manager:myself().\\n{nonode@nohost,{127,0,0,1},51063}\",\n      \"language\": \"erlang\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Usage\"\n}\n[/block]\nWhat can process groups be named?  They are just a term!\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-type group() :: term().\",\n      \"language\": \"erlang\"\n    }\n  ]\n}\n[/block]\nTo join a process to a group, just call `join` as you do not need to declare groups ahead of time.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"lasp_pg:join(group(), pid()) -> ok.\",\n      \"language\": \"erlang\"\n    }\n  ]\n}\n[/block]\nIf you want to remove a process from a group, that's also easily done with the `leave` command!\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"lasp_pg:leave(group(), pid()) -> ok.\",\n      \"language\": \"erlang\"\n    }\n  ]\n}\n[/block]\nYou can also return the current members of a group, too! (Without that, where would we be! :)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"lasp_pg:members(group()) -> {ok, sets:set(pid())}.\",\n      \"language\": \"erlang\"\n    }\n  ]\n}\n[/block]","excerpt":"Lasp PG is an eventually consistent, process registry for Erlang.","slug":"what-is-lasp-pg","type":"basic","title":"What is Lasp PG?"}

What is Lasp PG?

Lasp PG is an eventually consistent, process registry for Erlang.

Lasp PG is an eventually consistent, process registry for Erlang, the spiritual successor to [Riak PG](https://github.com/cmeiklejohn/riak_pg). Lasp PG is similar to facilities like `global` and `pg2`, but with many of the convergence anomalies removed through the use of CRDTs. Lasp PG completely bypasses distributed Erlang, and does full replication of the groups to all nodes in the cluster. It's based on CRDTs, and uses Lasp's underlying highly-available key-value store and membership layer ensuring high-scalability and fault-tolerance. [block:api-header] { "title": "Building" } [/block] Simple, clone it from GitHub and build! [block:code] { "codes": [ { "code": "$ git clone git@github.com:lasp-lang/lasp_pg.git\n$ cd lasp_pg\n$ make\n$ make check", "language": "shell" } ] } [/block] [block:api-header] { "title": "Clustering Nodes" } [/block] In order to join Lasp PG to other nodes in the system, you can use the clustering API directly to specify the name of a remote node. [block:code] { "codes": [ { "code": "> lasp_peer_service:join({Name, IP, Port}).", "language": "erlang" } ] } [/block] As Lasp PG relies on our Partisan library, to retrieve your node's name, IP address, and port, you can use the `myself` command provided by Partisan. [block:code] { "codes": [ { "code": "> partisan_peer_service_manager:myself().\n{nonode@nohost,{127,0,0,1},51063}", "language": "erlang" } ] } [/block] [block:api-header] { "title": "Usage" } [/block] What can process groups be named? They are just a term! [block:code] { "codes": [ { "code": "-type group() :: term().", "language": "erlang" } ] } [/block] To join a process to a group, just call `join` as you do not need to declare groups ahead of time. [block:code] { "codes": [ { "code": "lasp_pg:join(group(), pid()) -> ok.", "language": "erlang" } ] } [/block] If you want to remove a process from a group, that's also easily done with the `leave` command! [block:code] { "codes": [ { "code": "lasp_pg:leave(group(), pid()) -> ok.", "language": "erlang" } ] } [/block] You can also return the current members of a group, too! (Without that, where would we be! :) [block:code] { "codes": [ { "code": "lasp_pg:members(group()) -> {ok, sets:set(pid())}.", "language": "erlang" } ] } [/block]