Merge pull request #12000 from savonarola/1122-add-fdb-persistent-implementation

feat(ds): allow fdb implementation for durable storage
This commit is contained in:
Ilya Averyanov 2023-11-22 14:40:16 +02:00 committed by GitHub
commit 61246b4c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -62,7 +62,11 @@ storage_backend(#{
storage => {emqx_ds_storage_bitfield_lts, #{}},
n_shards => NShards,
replication_factor => ReplicationFactor
}.
};
storage_backend(#{
fdb := #{enable := true} = FDBConfig
}) ->
FDBConfig#{backend => fdb}.
%%--------------------------------------------------------------------

View File

@ -1781,7 +1781,7 @@ fields("session_storage_backend") ->
desc => ?DESC(session_storage_backend_builtin),
required => {false, recursively}
})}
];
] ++ emqx_schema_hooks:injection_point('session_persistence.storage_backends', []);
fields("session_storage_backend_builtin") ->
[
{"enable",

View File

@ -86,8 +86,14 @@
-type message_store_opts() :: #{}.
-type generic_db_opts() ::
#{
backend := atom(),
_ => _
}.
-type create_db_opts() ::
emqx_ds_replication_layer:builtin_db_opts().
emqx_ds_replication_layer:builtin_db_opts() | generic_db_opts().
-type message_id() :: emqx_ds_replication_layer:message_id().
@ -120,10 +126,11 @@
%% @doc Different DBs are completely independent from each other. They
%% could represent something like different tenants.
-spec open_db(db(), create_db_opts()) -> ok.
open_db(DB, Opts = #{backend := Backend}) when Backend =:= builtin ->
open_db(DB, Opts = #{backend := Backend}) when Backend =:= builtin orelse Backend =:= fdb ->
Module =
case Backend of
builtin -> emqx_ds_replication_layer
builtin -> emqx_ds_replication_layer;
fdb -> emqx_fdb_ds
end,
persistent_term:put(?persistent_term(DB), Module),
?module(DB):open_db(DB, Opts).