Merge pull request #12245 from savonarola/1229-improve-emqx_ds-interface

feat(ds): restore original add_generation/update_db_config callback semantics
This commit is contained in:
Ilya Averyanov 2023-12-29 14:40:42 +02:00 committed by GitHub
commit 02110bc79d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -22,7 +22,7 @@
-module(emqx_ds). -module(emqx_ds).
%% Management API: %% Management API:
-export([open_db/2, add_generation/2, add_generation/1, drop_db/1]). -export([open_db/2, update_db_config/2, add_generation/1, drop_db/1]).
%% Message storage API: %% Message storage API:
-export([store_batch/2, store_batch/3]). -export([store_batch/2, store_batch/3]).
@ -126,7 +126,7 @@
-callback add_generation(db()) -> ok | {error, _}. -callback add_generation(db()) -> ok | {error, _}.
-callback add_generation(db(), create_db_opts()) -> ok | {error, _}. -callback update_db_config(db(), create_db_opts()) -> ok | {error, _}.
-callback drop_db(db()) -> ok | {error, _}. -callback drop_db(db()) -> ok | {error, _}.
@ -162,9 +162,9 @@ open_db(DB, Opts = #{backend := Backend}) when Backend =:= builtin orelse Backen
add_generation(DB) -> add_generation(DB) ->
?module(DB):add_generation(DB). ?module(DB):add_generation(DB).
-spec add_generation(db(), create_db_opts()) -> ok. -spec update_db_config(db(), create_db_opts()) -> ok.
add_generation(DB, Opts) -> update_db_config(DB, Opts) ->
?module(DB):add_generation(DB, Opts). ?module(DB):update_db_config(DB, Opts).
%% @doc TODO: currently if one or a few shards are down, they won't be %% @doc TODO: currently if one or a few shards are down, they won't be

View File

@ -24,7 +24,7 @@
list_shards/1, list_shards/1,
open_db/2, open_db/2,
add_generation/1, add_generation/1,
add_generation/2, update_db_config/2,
drop_db/1, drop_db/1,
store_batch/3, store_batch/3,
get_streams/3, get_streams/3,
@ -130,8 +130,8 @@ add_generation(DB) ->
_ = emqx_ds_proto_v2:add_generation(Nodes, DB), _ = emqx_ds_proto_v2:add_generation(Nodes, DB),
ok. ok.
-spec add_generation(emqx_ds:db(), builtin_db_opts()) -> ok | {error, _}. -spec update_db_config(emqx_ds:db(), builtin_db_opts()) -> ok | {error, _}.
add_generation(DB, CreateOpts) -> update_db_config(DB, CreateOpts) ->
emqx_ds_replication_layer_meta:update_db_config(DB, CreateOpts). emqx_ds_replication_layer_meta:update_db_config(DB, CreateOpts).
-spec drop_db(emqx_ds:db()) -> ok | {error, _}. -spec drop_db(emqx_ds:db()) -> ok | {error, _}.

View File

@ -180,7 +180,7 @@ t_05_update_config(_Config) ->
{false, TimeAcc, [Msgs | MsgAcc]}; {false, TimeAcc, [Msgs | MsgAcc]};
(Datas, {Any, TimeAcc, MsgAcc}) -> (Datas, {Any, TimeAcc, MsgAcc}) ->
timer:sleep(500), timer:sleep(500),
?assertMatch(ok, emqx_ds:add_generation(DB, opts())), ?assertMatch(ok, emqx_ds:update_db_config(DB, opts())),
timer:sleep(500), timer:sleep(500),
StartTime = emqx_message:timestamp_now(), StartTime = emqx_message:timestamp_now(),
Msgs = ToMsgs(Datas), Msgs = ToMsgs(Datas),