Skip to content

Instantly share code, notes, and snippets.

@zkessin
Created July 25, 2017 11:04
Show Gist options
  • Save zkessin/64893a5cf055a99255c1b6edc75745ac to your computer and use it in GitHub Desktop.
Save zkessin/64893a5cf055a99255c1b6edc75745ac to your computer and use it in GitHub Desktop.
-module(replication_ssce).
-export([test/0]).
test() ->
DBS = [<<"50c84cda-e011-49d3-889a-0b2ad8206e6c">>,
<<"774129ae-db15-431e-9ded-fbfb924b33b2">>],
[S,T] = DBS,
[begin
lager:info("Create Database ~s", [D]),
{ok,#{<<"database_id">> := D}} = create_database(D)
end
|| D <-DBS],
{ok, #{id := Id}} = barrel:start_replication(#{source => S,
target => T,
options => #{metrics_freq => 100}}),
ok = barrel:stop_replication(Id),
[begin
barrel:delete_database(D)
end
|| D <-DBS],
ok.
create_database(DB) ->
case barrel:database_infos(DB) of
{ok, _} -> barrel:delete_database(DB);
_ -> ok
end,
barrel:create_database(#{<<"database_id">> => DB}).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment