Skip to content

Commit

Permalink
add util function
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro M. Ramallo <alejandro.ramallo@leapsight.com>
  • Loading branch information
aramallo committed Oct 4, 2023
1 parent fef5a6f commit e8088f5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/partisan_plumtree_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
%% API
-export([start_link/0]).
-export([start_link/1]).
-export([timestamps/0]).

%% transmission callbacks
-export([extract_log_type_and_payload/1]).
Expand Down Expand Up @@ -117,6 +118,22 @@ start_link(Opts) ->
gen_server:start_link({local, ?MODULE}, ?MODULE, Opts, []).


%% -----------------------------------------------------------------------------
%% @doc Returns all the timestamps.
%%
%% Notice this can copy a lot of data from the ets table to the calling process.
%% @end
%% -----------------------------------------------------------------------------
-spec timestamps() -> [timestamp()].

timestamps() ->
try
ets:tab2list(?MODULE)
catch
error:badarg ->
[]
end.


%% -----------------------------------------------------------------------------
%% @doc
Expand Down Expand Up @@ -188,6 +205,7 @@ merge(Timestamp, Timestamp) ->
case is_stale(Timestamp) of
true ->
false;

false ->
gen_server:call(?MODULE, {merge, Timestamp}, infinity),
true
Expand Down

0 comments on commit e8088f5

Please sign in to comment.