From a33977e635f254e4a7a40dd73def20a6b5f5822d Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Mon, 31 Oct 2022 15:08:25 -0300 Subject: [PATCH] feat: add ets table creation to jwt supervisor --- .../src/emqx_rule_engine_jwt_sup.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/emqx_rule_engine/src/emqx_rule_engine_jwt_sup.erl b/apps/emqx_rule_engine/src/emqx_rule_engine_jwt_sup.erl index 72ead42ab..18cc48c9e 100644 --- a/apps/emqx_rule_engine/src/emqx_rule_engine_jwt_sup.erl +++ b/apps/emqx_rule_engine/src/emqx_rule_engine_jwt_sup.erl @@ -25,12 +25,15 @@ -export([init/1]). +-include_lib("emqx_rule_engine/include/rule_actions.hrl"). + -type worker_id() :: term(). start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). init([]) -> + ensure_jwt_table(), SupFlags = #{ strategy => one_for_one , intensity => 10 , period => 5 @@ -73,3 +76,15 @@ jwt_worker_child_spec(Id, Config, Ref) -> , shutdown => brutal_kill , modules => [emqx_rule_engine_jwt_worker] }. + +-spec ensure_jwt_table() -> ok. +ensure_jwt_table() -> + case ets:whereis(?JWT_TABLE) of + undefined -> + Opts = [named_table, public, + {read_concurrency, true}, ordered_set], + _ = ets:new(?JWT_TABLE, Opts), + ok; + _ -> + ok + end.