feat(dsrepl): add API to get current DB replication sites
This commit is contained in:
parent
ad52f7838e
commit
bb8ffee18c
|
@ -49,6 +49,7 @@
|
||||||
assign_db_sites/2,
|
assign_db_sites/2,
|
||||||
replica_set_transitions/2,
|
replica_set_transitions/2,
|
||||||
update_replica_set/3,
|
update_replica_set/3,
|
||||||
|
db_sites/1,
|
||||||
replica_set/2,
|
replica_set/2,
|
||||||
target_set/2
|
target_set/2
|
||||||
]).
|
]).
|
||||||
|
@ -243,6 +244,17 @@ assign_db_sites(DB, Sites) ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec db_sites(emqx_ds:db()) -> [site()].
|
||||||
|
db_sites(DB) ->
|
||||||
|
Recs = mnesia:dirty_match_object(?SHARD_TAB, ?SHARD_PAT({DB, '_'})),
|
||||||
|
lists:foldl(
|
||||||
|
fun(#?SHARD_TAB{replica_set = RS}, Acc) ->
|
||||||
|
ordsets:union(ordsets:from_list(RS), Acc)
|
||||||
|
end,
|
||||||
|
ordsets:new(),
|
||||||
|
Recs
|
||||||
|
).
|
||||||
|
|
||||||
-spec replica_set_transitions(emqx_ds:db(), emqx_ds_replication_layer:shard_id()) ->
|
-spec replica_set_transitions(emqx_ds:db(), emqx_ds_replication_layer:shard_id()) ->
|
||||||
[transition()] | undefined.
|
[transition()] | undefined.
|
||||||
replica_set_transitions(DB, Shard) ->
|
replica_set_transitions(DB, Shard) ->
|
||||||
|
|
Loading…
Reference in New Issue