Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.

lasp-lang/lasp

Folders and files

NameName
Last commit message
Last commit date
Dec 27, 2019
Dec 7, 2017
Dec 13, 2016
Dec 15, 2016
Apr 7, 2016
Nov 25, 2017
Oct 11, 2016
Nov 26, 2015
Oct 18, 2018
Jul 11, 2016
Dec 27, 2019
Jan 12, 2021
Jan 12, 2021
Sep 10, 2014
Nov 17, 2017
Feb 15, 2019
Dec 7, 2017
Oct 5, 2017
Apr 17, 2018
May 13, 2016
Dec 27, 2019
Jan 8, 2021
Nov 26, 2015
Feb 26, 2016
Jan 10, 2018
Sep 29, 2015
Jan 1, 2020
Jan 1, 2020
Feb 14, 2019

Repository files navigation

Lasp

Build Status

Overview

Lasp is a programming model for synchronization-free computations.

Installing

Lasp requires Erlang 19 or greater. Once you have Erlang installed, do the following to install and build Lasp.

$ git clone [email protected]:lasp-lang/lasp.git
$ cd lasp
$ make

Creating a small cluster

Clone Lasp:

$ git clone https://github.com/lasp-lang/lasp.git

Run two shells

$ rebar3 shell --name [email protected]
$ rebar3 shell --name [email protected]

Exceute to node a:

1> lasp_peer_service:join('[email protected]').
ok
2> lasp_peer_service:members().
{ok,['[email protected]','[email protected]']}

Execute node b:

1> lasp_peer_service:members().
{ok,['[email protected]','[email protected]']}     

Go back to node a and run:

3> Content = #{what => i_am_an_awmap_value}.

% create a lasp CRDT
AwMapVarName = <<"awmap">>.
Key1 = <<"key1">>.
AwMapType = {state_awmap, [state_mvregister]}.
{ok, {AwMap, _, _, _}} = lasp:declare({AwMapVarName, AwMapType}, AwMapType).

% Update the CRDT with the content
{ok, _} = lasp:update(AwMap, {apply, Key1, {set, nil, Content}}, term_to_binary(self())).

Go to node b and retrieve the content of the CRDT:

2> {ok,[{_, AwMapSet}]} = lasp:query({<<"awmap">>,{state_awmap,[state_mvregister]}}).

3> sets:to_list(AwMapSet).
% [#{what => i_am_an_awmap_value}]

Running a shell

You can run a Erlang shell where you can interact with a Lasp node by doing the following:

$ make shell

Running the test suite

To run the test suite, which will execute all of the Lasp scenarios, use the following command.

$ make check

Notes

If using the Distributed Erlang backend, make sure that all nodes are configured to use the same cookie.

Code examples

This blog post by @marianoguerra contains concise sample code.