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

No longer use non-binary term in update. #312

Merged
merged 4 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ 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}}, self()).
{ok, _} = lasp:update(AwMap, {apply, Key1, {set, nil, Content}}, term_to_binary(self())).
```

Go to node b and retrieve the content of the CRDT:
Expand Down
6 changes: 5 additions & 1 deletion src/lasp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ declare(Id, Type) ->
%% at the given `Id'.
%%
-spec update(id(), operation(), actor()) -> {ok, var()} | {error, timeout}.
update(Id, Operation, Actor) ->
update(Id, Operation, Actor) when is_list(Actor) ->
do(update, [Id, Operation, Actor]);
update(Id, Operation, Actor) when is_binary(Actor) ->
do(update, [Id, Operation, Actor]);
update(Id, Operation, Actor) when is_atom(Actor) ->
do(update, [Id, Operation, Actor]).

%% @doc Bind a dataflow variable to a value.
Expand Down
36 changes: 18 additions & 18 deletions test/lasp_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -860,9 +860,9 @@ counter_enforce_once_test(Config) ->
end,

%% Increment counter twice to get trigger to fire.
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, term_to_binary(self())]),

lager:info("Waiting for response..."),
receive
Expand Down Expand Up @@ -924,9 +924,9 @@ counter_strict_enforce_once_test(Config) ->
timer:sleep(1000),

%% Increment counter twice to get trigger to fire.
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, increment, term_to_binary(self())]),

lager:info("Waiting for response..."),
receive
Expand Down Expand Up @@ -981,9 +981,9 @@ awset_enforce_once_test(Config) ->
end,

%% Increment counter twice to get trigger to fire.
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, term_to_binary(self())]),

lager:info("Waiting for response..."),
receive
Expand Down Expand Up @@ -1035,9 +1035,9 @@ awset_strict_enforce_once_test(Config) ->
end,

%% Increment counter twice to get trigger to fire.
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, term_to_binary(self())]),

lager:info("Waiting for response..."),
receive
Expand Down Expand Up @@ -1089,9 +1089,9 @@ orset_enforce_once_test(Config) ->
end,

%% Increment counter twice to get trigger to fire.
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, term_to_binary(self())]),

lager:info("Waiting for response..."),
receive
Expand Down Expand Up @@ -1143,9 +1143,9 @@ orset_strict_enforce_once_test(Config) ->
end,

%% Increment counter twice to get trigger to fire.
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, self()]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 1}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 2}, term_to_binary(self())]),
{ok, _} = rpc:call(Node, lasp, update, [Id, {add, 3}, term_to_binary(self())]),

lager:info("Waiting for response..."),
receive
Expand Down