فهرست منبع

feat(ds): allow fdb implementation for durable storage

Ilya Averyanov 2 سال پیش
والد
کامیت
a1b9a14fa1
3فایلهای تغییر یافته به همراه16 افزوده شده و 5 حذف شده
  1. 5 1
      apps/emqx/src/emqx_persistent_message.erl
  2. 1 1
      apps/emqx/src/emqx_schema.erl
  3. 10 3
      apps/emqx_durable_storage/src/emqx_ds.erl

+ 5 - 1
apps/emqx/src/emqx_persistent_message.erl

@@ -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}.
 
 %%--------------------------------------------------------------------
 

+ 1 - 1
apps/emqx/src/emqx_schema.erl

@@ -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",

+ 10 - 3
apps/emqx_durable_storage/src/emqx_ds.erl

@@ -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).