From 13803f9159ecf64538416c9d120fdd6023092b54 Mon Sep 17 00:00:00 2001 From: k32 <10274441+k32@users.noreply.github.com> Date: Mon, 14 Jun 2021 12:00:27 +0200 Subject: [PATCH] feat(rlog): Add RLOG to EMQX --- .gitignore | 1 + apps/emqx/rebar.config | 2 +- apps/emqx/src/emqx_app.erl | 5 +++++ apps/emqx/src/emqx_schema.erl | 7 +++++++ rebar.config | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 218b22261..dd8e9b82e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ dist.zip scripts/git-token etc/*.seg _upgrade_base/ +TAGS diff --git a/apps/emqx/rebar.config b/apps/emqx/rebar.config index 2c566d7f8..a6e4e6864 100644 --- a/apps/emqx/rebar.config +++ b/apps/emqx/rebar.config @@ -13,7 +13,7 @@ , {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}} , {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.8.2"}}} , {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.8.0"}}} - , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.9.0"}}} + , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.10.0"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} , {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v4.0.1"}}} %% todo delete when plugins use hocon , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.0"}}} diff --git a/apps/emqx/src/emqx_app.erl b/apps/emqx/src/emqx_app.erl index 8501243a8..26b81c8e7 100644 --- a/apps/emqx/src/emqx_app.erl +++ b/apps/emqx/src/emqx_app.erl @@ -24,8 +24,12 @@ , get_release/0 ]). +-include("emqx.hrl"). + -define(APP, emqx). +-define(EMQX_SHARDS, []). + -include("emqx_release.hrl"). %%-------------------------------------------------------------------- @@ -39,6 +43,7 @@ start(_Type, _Args) -> %% Load application first for ekka_mnesia scanner _ = load_ce_modules(), ekka:start(), + ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity), {ok, Sup} = emqx_sup:start_link(), ok = start_autocluster(), ok = emqx_plugins:init(), diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index bac2e5cfe..3fb60a6a6 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -60,6 +60,7 @@ fields("cluster") -> , {"dns", ref("dns")} , {"etcd", ref("etcd")} , {"k8s", ref("k8s")} + , {"rlog", ref("rlog")} ]; fields("static") -> @@ -98,6 +99,12 @@ fields("k8s") -> , {"suffix", t(string(), undefined, "")} ]; +fields("rlog") -> + [ {"backend", t(union([mnesia, rlog]), "ekka.db_backend", mnesia)} + , {"role", t(union([core, replicant]), "ekka.node_role", core)} + , {"core_nodes", t(comma_separated_list(), "ekka.core_nodes", [])} + ]; + fields("node") -> [ {"name", t(string(), "vm_args.-name", "emqx@127.0.0.1", "NODE_NAME")} , {"ssl_dist_optfile", t(string(), "vm_args.-ssl_dist_optfile", undefined)} diff --git a/rebar.config b/rebar.config index f123d93b2..696fc6000 100644 --- a/rebar.config +++ b/rebar.config @@ -39,7 +39,7 @@ , {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}} , {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.8.2"}}} , {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.8.0"}}} - , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.9.0"}}} + , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.10.0"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} , {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v4.0.1"}}} % TODO: delete when all apps moved to hocon , {minirest, {git, "https://github.com/emqx/minirest", {tag, "0.3.5"}}}