From 983dd16b0698ec11a545e8a467b3e3c9d1c71632 Mon Sep 17 00:00:00 2001 From: Chase Pursley Date: Sun, 7 Jan 2024 16:04:13 -0500 Subject: [PATCH 1/3] Config: Move modules under destinations. --- lib/walex/config/config.ex | 17 ++++---- lib/walex/destinations/event_modules.ex | 2 +- test/walex/config/config_test.exs | 54 ++++++++++++------------- test/walex/event/event_dsl_test.exs | 2 +- test/walex/event/event_test.exs | 2 +- 5 files changed, 38 insertions(+), 39 deletions(-) diff --git a/lib/walex/config/config.ex b/lib/walex/config/config.ex index df707bc..2ed7752 100644 --- a/lib/walex/config/config.ex +++ b/lib/walex/config/config.ex @@ -86,23 +86,24 @@ defmodule WalEx.Config do name = Keyword.get(configs, :name) subscriptions = Keyword.get(configs, :subscriptions, []) - modules = Keyword.get(configs, :modules, []) + destinations = Keyword.get(configs, :destinations, []) + modules = Keyword.get(destinations, :modules, []) + module_names = build_module_names(name, modules, subscriptions) [ name: name, - publication: Keyword.get(configs, :publication), - subscriptions: subscriptions, - modules: build_module_names(name, modules, subscriptions), - destinations: Keyword.get(configs, :destinations), - webhook_signing_secret: Keyword.get(configs, :webhook_signing_secret), - event_relay: Keyword.get(configs, :event_relay), hostname: Keyword.get(configs, :hostname, db_configs_from_url[:hostname]), username: Keyword.get(configs, :username, db_configs_from_url[:username]), password: Keyword.get(configs, :password, db_configs_from_url[:password]), port: Keyword.get(configs, :port, db_configs_from_url[:port]), database: Keyword.get(configs, :database, db_configs_from_url[:database]), ssl: Keyword.get(configs, :ssl, false), - ssl_opts: Keyword.get(configs, :ssl_opts, verify: :verify_none) + ssl_opts: Keyword.get(configs, :ssl_opts, verify: :verify_none), + subscriptions: subscriptions, + publication: Keyword.get(configs, :publication), + destinations: Keyword.put(destinations, :modules, module_names), + webhook_signing_secret: Keyword.get(configs, :webhook_signing_secret), + event_relay: Keyword.get(configs, :event_relay) ] end diff --git a/lib/walex/destinations/event_modules.ex b/lib/walex/destinations/event_modules.ex index 453dede..0baa0c7 100755 --- a/lib/walex/destinations/event_modules.ex +++ b/lib/walex/destinations/event_modules.ex @@ -33,7 +33,7 @@ defmodule WalEx.Destinations.EventModules do @impl true def handle_call({:process, txn, server}, _from, state) do server - |> WalEx.Config.get_configs([:modules]) + |> WalEx.Config.get_configs(:destinations) |> process_events(txn) {:reply, :ok, state} diff --git a/test/walex/config/config_test.exs b/test/walex/config/config_test.exs index c3e4c83..66e2b51 100644 --- a/test/walex/config/config_test.exs +++ b/test/walex/config/config_test.exs @@ -11,11 +11,11 @@ defmodule WalEx.ConfigTest do password: "password", database: "database", port: 5432, + ssl: false, + ssl_opts: [verify: :verify_none], subscriptions: ["subscriptions"], publication: "publication", - modules: [MyApp.CustomModule], - ssl: false, - ssl_opts: [verify: :verify_none] + destinations: [modules: [MyApp.CustomModule]] ] setup_all do @@ -26,20 +26,17 @@ defmodule WalEx.ConfigTest do describe "start_link/2" do test "should start a process" do - {:ok, pid} = Config.start_link(configs: @base_configs) + assert {:ok, pid} = Config.start_link(configs: @base_configs) assert is_pid(pid) end test "should accept database url as config and split it into the right configs" do configs = [ name: :test_name, - url: "postgres://username:password@hostname:5432/database", - subscriptions: ["subscriptions"], - publication: "publication", - modules: ["modules"] + url: "postgres://username:password@hostname:5432/database" ] - {:ok, pid} = Config.start_link(configs: configs) + assert {:ok, pid} = Config.start_link(configs: configs) assert is_pid(pid) assert [ @@ -51,15 +48,18 @@ defmodule WalEx.ConfigTest do ssl: false, ssl_opts: [verify: :verify_none] ] == - Config.get_configs(:test_name, [ - :hostname, - :username, - :password, - :database, - :port, - :ssl, - :ssl_opts - ]) + Config.get_configs( + :test_name, + [ + :hostname, + :username, + :password, + :database, + :port, + :ssl, + :ssl_opts + ] + ) end end @@ -72,19 +72,18 @@ defmodule WalEx.ConfigTest do test "should return all configs" do assert [ name: :test_name, - publication: "publication", - subscriptions: ["subscriptions"], - modules: [MyApp.CustomModule, :"TestName.Events.Subscriptions"], - destinations: nil, - webhook_signing_secret: nil, - event_relay: nil, hostname: "hostname", username: "username", password: "password", port: 5432, database: "database", ssl: false, - ssl_opts: [verify: :verify_none] + ssl_opts: [verify: :verify_none], + subscriptions: ["subscriptions"], + publication: "publication", + destinations: [modules: [MyApp.CustomModule, :"TestName.Events.Subscriptions"]], + webhook_signing_secret: nil, + event_relay: nil ] == Config.get_configs(:test_name) end end @@ -101,12 +100,11 @@ defmodule WalEx.ConfigTest do test "should return only selected configs when second parameter is a list" do assert [ - modules: [MyApp.CustomModule, :"TestName.Events.Subscriptions"], hostname: "hostname", ssl: false, ssl_opts: [verify: :verify_none] ] == - Config.get_configs(:test_name, [:modules, :hostname, :ssl, :ssl_opts]) + Config.get_configs(:test_name, [:hostname, :ssl, :ssl_opts]) end test "should filter configs by process name" do @@ -115,7 +113,7 @@ defmodule WalEx.ConfigTest do |> Keyword.replace(:name, :other_name) |> Keyword.replace(:database, "other_database") - {:ok, pid} = Config.start_link(configs: configs) + assert {:ok, pid} = Config.start_link(configs: configs) assert is_pid(pid) assert [ diff --git a/test/walex/event/event_dsl_test.exs b/test/walex/event/event_dsl_test.exs index 41d265c..5b185f0 100644 --- a/test/walex/event/event_dsl_test.exs +++ b/test/walex/event/event_dsl_test.exs @@ -21,7 +21,7 @@ defmodule WalEx.EventDslTest do port: 5432, subscriptions: ["user", "todo"], publication: ["events"], - modules: [TestApp.DslTestModule] + destinations: [modules: [TestApp.DslTestModule]] ] describe "on_event/2" do diff --git a/test/walex/event/event_test.exs b/test/walex/event/event_test.exs index 4c20b28..ad24187 100644 --- a/test/walex/event/event_test.exs +++ b/test/walex/event/event_test.exs @@ -23,7 +23,7 @@ defmodule WalEx.EventTest do port: 5432, subscriptions: ["user", "todo"], publication: ["events"], - modules: [TestApp.TestModule] + destinations: [modules: [TestApp.TestModule]] ] describe "process_all/1" do From fd2732d65ff7e4001a99b201e66835ced3a1bd7c Mon Sep 17 00:00:00 2001 From: Chase Pursley Date: Sun, 7 Jan 2024 17:21:10 -0500 Subject: [PATCH 2/3] Determine if modules exist at compile time. --- lib/walex/config/config.ex | 14 ++- lib/walex/destinations/event_modules.ex | 8 +- test/walex/config/config_test.exs | 133 +++++++++++++----------- 3 files changed, 88 insertions(+), 67 deletions(-) diff --git a/lib/walex/config/config.ex b/lib/walex/config/config.ex index 2ed7752..bc904c6 100644 --- a/lib/walex/config/config.ex +++ b/lib/walex/config/config.ex @@ -113,6 +113,7 @@ defmodule WalEx.Config do |> map_subscriptions_to_modules(name) |> Enum.concat(modules) |> Enum.uniq() + |> map_existing_modules() |> Enum.sort() end @@ -128,7 +129,6 @@ defmodule WalEx.Config do def to_module_name(module_name) when is_atom(module_name) or is_binary(module_name) do module_name |> to_string() - |> String.replace("Elixir.", "") |> String.split(["_"]) |> Enum.map_join(&capitalize/1) end @@ -141,6 +141,18 @@ defmodule WalEx.Config do end end + defp module_exists?(module_name) do + case Code.ensure_compiled(module_name) do + {:module, _module} -> + true + + {:error, _error} -> + false + end + end + + defp map_existing_modules(modules), do: Enum.filter(modules, &module_exists?/1) + defp parse_url(""), do: [] defp parse_url(url) when is_binary(url) do diff --git a/lib/walex/destinations/event_modules.ex b/lib/walex/destinations/event_modules.ex index 0baa0c7..553cdde 100755 --- a/lib/walex/destinations/event_modules.ex +++ b/lib/walex/destinations/event_modules.ex @@ -52,13 +52,7 @@ defmodule WalEx.Destinations.EventModules do end defp process_module(module_name, functions, txn) do - case Code.ensure_compiled(module_name) do - {:module, module} -> - Enum.each(functions, &apply_process_macro(&1, module, txn)) - - {:error, _error} -> - :ok - end + Enum.each(functions, &apply_process_macro(&1, module_name, txn)) end defp apply_process_macro(function, module, txn) do diff --git a/test/walex/config/config_test.exs b/test/walex/config/config_test.exs index 66e2b51..4a89bbe 100644 --- a/test/walex/config/config_test.exs +++ b/test/walex/config/config_test.exs @@ -4,12 +4,18 @@ defmodule WalEx.ConfigTest do alias WalEx.Config alias Config.Registry, as: WalExRegistry + @app_name :my_app + @hostname "hostname" + @username "username" + @password "password" + @database "database" + @base_configs [ - name: :test_name, - hostname: "hostname", - username: "username", - password: "password", - database: "database", + name: @app_name, + hostname: @hostname, + username: @username, + password: @password, + database: @database, port: 5432, ssl: false, ssl_opts: [verify: :verify_none], @@ -32,7 +38,7 @@ defmodule WalEx.ConfigTest do test "should accept database url as config and split it into the right configs" do configs = [ - name: :test_name, + name: @app_name, url: "postgres://username:password@hostname:5432/database" ] @@ -40,16 +46,16 @@ defmodule WalEx.ConfigTest do assert is_pid(pid) assert [ - hostname: "hostname", - username: "username", - password: "password", + hostname: @hostname, + username: @username, + password: @password, port: 5432, - database: "database", + database: @database, ssl: false, ssl_opts: [verify: :verify_none] ] == Config.get_configs( - :test_name, + @app_name, [ :hostname, :username, @@ -71,20 +77,20 @@ defmodule WalEx.ConfigTest do test "should return all configs" do assert [ - name: :test_name, - hostname: "hostname", - username: "username", - password: "password", + name: @app_name, + hostname: @hostname, + username: @username, + password: @password, port: 5432, - database: "database", + database: @database, ssl: false, ssl_opts: [verify: :verify_none], subscriptions: ["subscriptions"], publication: "publication", - destinations: [modules: [MyApp.CustomModule, :"TestName.Events.Subscriptions"]], + destinations: [modules: [MyApp.CustomModule]], webhook_signing_secret: nil, event_relay: nil - ] == Config.get_configs(:test_name) + ] == Config.get_configs(@app_name) end end @@ -95,16 +101,16 @@ defmodule WalEx.ConfigTest do end test "should return only selected configs when second parameter is an atom" do - assert ["subscriptions"] == Config.get_configs(:test_name, :subscriptions) + assert ["subscriptions"] == Config.get_configs(@app_name, :subscriptions) end test "should return only selected configs when second parameter is a list" do assert [ - hostname: "hostname", + hostname: @hostname, ssl: false, ssl_opts: [verify: :verify_none] ] == - Config.get_configs(:test_name, [:hostname, :ssl, :ssl_opts]) + Config.get_configs(@app_name, [:hostname, :ssl, :ssl_opts]) end test "should filter configs by process name" do @@ -117,12 +123,12 @@ defmodule WalEx.ConfigTest do assert is_pid(pid) assert [ - name: :test_name, - database: "database", + name: @app_name, + database: @database, ssl: false, ssl_opts: [verify: :verify_none] ] == - Config.get_configs(:test_name, [:database, :name, :ssl, :ssl_opts]) + Config.get_configs(@app_name, [:database, :name, :ssl, :ssl_opts]) assert [ name: :other_name, @@ -141,20 +147,20 @@ defmodule WalEx.ConfigTest do end test "should add new values when new_values is a list" do - Config.add_config(:test_name, :subscriptions, [ + Config.add_config(@app_name, :subscriptions, [ "new_subscriptions_1", "new_subscriptions_2" ]) assert ["subscriptions", "new_subscriptions_1", "new_subscriptions_2"] == - Config.get_configs(:test_name)[:subscriptions] + Config.get_configs(@app_name)[:subscriptions] end test "should add new values when new_value is not a list" do - Config.add_config(:test_name, :subscriptions, "new_subscriptions") + Config.add_config(@app_name, :subscriptions, "new_subscriptions") assert ["subscriptions", "new_subscriptions"] == - Config.get_configs(:test_name)[:subscriptions] + Config.get_configs(@app_name)[:subscriptions] end end @@ -165,18 +171,18 @@ defmodule WalEx.ConfigTest do end test "should remove existing value from list if it exists" do - Config.add_config(:test_name, :subscriptions, [ + Config.add_config(@app_name, :subscriptions, [ "new_subscriptions_1", "new_subscriptions_2" ]) assert ["subscriptions", "new_subscriptions_1", "new_subscriptions_2"] == - Config.get_configs(:test_name)[:subscriptions] + Config.get_configs(@app_name)[:subscriptions] - Config.remove_config(:test_name, :subscriptions, "subscriptions") + Config.remove_config(@app_name, :subscriptions, "subscriptions") assert ["new_subscriptions_1", "new_subscriptions_2"] == - Config.get_configs(:test_name)[:subscriptions] + Config.get_configs(@app_name)[:subscriptions] end end @@ -187,41 +193,42 @@ defmodule WalEx.ConfigTest do end test "should replace existing value when value is not a list" do - assert "password" == Config.get_configs(:test_name)[:password] + assert @password == Config.get_configs(@app_name)[:password] - Config.replace_config(:test_name, :password, "new_password") + Config.replace_config(@app_name, :password, "new_password") - assert "new_password" == Config.get_configs(:test_name)[:password] + assert "new_password" == Config.get_configs(@app_name)[:password] end end - describe "build_module_names/3" do - setup do - {:ok, _pid} = Config.start_link(configs: @base_configs) - :ok - end + # # Need to find a way to load the MyApp.Events.Subscriptions + # describe "build_module_names/3" do + # setup do + # {:ok, _pid} = Config.start_link(configs: @base_configs) + # :ok + # end - test "should create list of modules from subscriptions config when no modules" do - subscriptions = ["subscriptions"] + # test "should create list of modules from subscriptions config when no modules" do + # subscriptions = ["subscriptions"] - assert [:"TestName.Events.Subscriptions"] == - Config.build_module_names(:test_name, [], subscriptions) - end + # assert [:"MyApp.Events.Subscriptions"] == + # Config.build_module_names(@app_name, [], subscriptions) + # end - test "should create list of modules from modules config when no subscriptions" do - modules = [MyApp.CustomModule] + # test "should create list of modules from modules config when no subscriptions" do + # modules = [MyApp.CustomModule] - assert modules == Config.build_module_names(:test_name, modules, []) - end + # assert modules == Config.build_module_names(@app_name, modules, []) + # end - test "should create list of modules when both modules and subscriptions config" do - subscriptions = ["subscriptions"] - modules = [MyApp.CustomModule] + # test "should create list of modules when both modules and subscriptions config" do + # subscriptions = ["subscriptions"] + # modules = [MyApp.CustomModule] - assert [MyApp.CustomModule, :"TestName.Events.Subscriptions"] == - Config.build_module_names(:test_name, modules, subscriptions) - end - end + # assert [MyApp.CustomModule, :"MyApp.Events.Subscriptions"] == + # Config.build_module_names(@app_name, modules, subscriptions) + # end + # end describe "to_module_name/1" do setup do @@ -230,15 +237,23 @@ defmodule WalEx.ConfigTest do end test "should convert standard atom into Module atom" do - assert "TestName" == Config.to_module_name(:test_name) + assert "MyApp" == Config.to_module_name(@app_name) end test "should convert binary string into Module atom" do - assert "TestName" == Config.to_module_name("test_name") + assert "MyApp" == Config.to_module_name("my_app") end test "should convert remove 'Elixir.' from module name" do - assert "TestName" == Config.to_module_name(:"Elixir.TestName") + assert "Elixir.MyApp" == Config.to_module_name(:"Elixir.MyApp") end end end + +defmodule MyApp.CustomModule do + # use WalEx.Event, name: :test_name +end + +# defmodule MyApp.Events.Subscriptions do +# use WalEx.Event, name: :my_app +# end From 348faaf07079684cfe5b6d9e988bca158fb5f349 Mon Sep 17 00:00:00 2001 From: Chase Pursley Date: Sun, 7 Jan 2024 17:47:31 -0500 Subject: [PATCH 3/3] Destinations Supervisor: Conditionally start. --- lib/walex/config/config.ex | 19 ++++++++++++ lib/walex/destinations/destinations.ex | 6 ++-- lib/walex/destinations/event_relay.ex | 2 +- lib/walex/destinations/supervisor.ex | 40 ++++++++++++++------------ lib/walex/destinations/webhooks.ex | 2 +- lib/walex/event/event.ex | 5 ++-- lib/walex/helpers.ex | 20 ------------- 7 files changed, 48 insertions(+), 46 deletions(-) diff --git a/lib/walex/config/config.ex b/lib/walex/config/config.ex index bc904c6..6b3e6e9 100644 --- a/lib/walex/config/config.ex +++ b/lib/walex/config/config.ex @@ -43,6 +43,25 @@ defmodule WalEx.Config do |> Keyword.take(keys) end + def get_database(app_name), do: get_configs(app_name, :database) + + def get_destination(app_name, destination) do + case get_configs(app_name, :destinations) do + destinations when is_list(destinations) and destinations != [] -> + destinations + |> Keyword.get(destination, nil) + + _ -> + nil + end + end + + def get_event_modules(app_name), do: get_destination(app_name, :modules) + + def get_webhooks(app_name), do: get_destination(app_name, :webhooks) + + def get_event_relay_topic(app_name), do: get_destination(app_name, :event_relay_topic) + def add_config(app_name, key, new_values) when is_list(new_values) and key in @allowed_config_values do Agent.update(set_agent(app_name), fn config -> diff --git a/lib/walex/destinations/destinations.ex b/lib/walex/destinations/destinations.ex index 8494452..ade50fc 100644 --- a/lib/walex/destinations/destinations.ex +++ b/lib/walex/destinations/destinations.ex @@ -5,7 +5,7 @@ defmodule WalEx.Destinations do use GenServer - alias WalEx.{Destinations, Config, Event, Helpers, TransactionFilter} + alias WalEx.{Destinations, Config, Event, TransactionFilter} alias Config.Registry alias Destinations.{EventModules, EventRelay, Webhooks} @@ -65,7 +65,7 @@ defmodule WalEx.Destinations do defp process_event_relay([], _app_name), do: :ok defp process_event_relay(filtered_events, app_name) do - event_relay_topic = Helpers.get_event_relay_topic(app_name) + event_relay_topic = Config.get_event_relay_topic(app_name) if is_binary(event_relay_topic) and event_relay_topic != "" do EventRelay.process(filtered_events, app_name) @@ -75,7 +75,7 @@ defmodule WalEx.Destinations do defp process_webhooks([], _app_name), do: :ok defp process_webhooks(filtered_events, app_name) do - webhooks = Helpers.get_webhooks(app_name) + webhooks = Config.get_webhooks(app_name) if is_list(webhooks) and webhooks != [] do Webhooks.process(filtered_events, app_name) diff --git a/lib/walex/destinations/event_relay.ex b/lib/walex/destinations/event_relay.ex index be8e484..d286153 100644 --- a/lib/walex/destinations/event_relay.ex +++ b/lib/walex/destinations/event_relay.ex @@ -46,7 +46,7 @@ defmodule WalEx.Destinations.EventRelay do def process_events(changes, app_name) do case connect(app_name) do {:ok, channel} -> - topic = Helpers.get_event_relay_topic(app_name) + topic = Config.get_event_relay_topic(app_name) events = build_events(changes) request = diff --git a/lib/walex/destinations/supervisor.ex b/lib/walex/destinations/supervisor.ex index 397b485..439de18 100644 --- a/lib/walex/destinations/supervisor.ex +++ b/lib/walex/destinations/supervisor.ex @@ -9,40 +9,44 @@ defmodule WalEx.Destinations.Supervisor do def start_link(opts) do app_name = Keyword.get(opts, :app_name) - name = WalEx.Config.Registry.set_name(:set_supervisor, __MODULE__, app_name) + name = Config.Registry.set_name(:set_supervisor, __MODULE__, app_name) Supervisor.start_link(__MODULE__, configs: opts, name: name) end @impl true def init(opts) do - configs = Keyword.get(opts, :configs) - app_name = Keyword.get(configs, :name) + app_name = + opts + |> Keyword.get(:configs) + |> Keyword.get(:name) children = - [ - {Destinations, app_name: app_name}, - # TODO: EventModules should be dynamic (only if modules exist) - {EventModules, app_name: app_name} - ] - |> maybe_webhooks(configs) - |> maybe_event_relay(configs) + [{Destinations, app_name: app_name}] + |> maybe_event_modules(app_name) + |> maybe_webhooks(app_name) + |> maybe_event_relay(app_name) Supervisor.init(children, strategy: :one_for_all) end - defp maybe_webhooks(children, configs) do - app_name = Keyword.get(configs, :name) - destinations = Keyword.get(configs, :destinations) - has_webhook_config = Config.has_config?(destinations, :webhooks) + defp maybe_event_modules(children, app_name) do + modules = Config.get_event_modules(app_name) + has_module_config = is_list(modules) and modules != [] + + maybe_set_child(children, has_module_config, {EventModules, app_name: app_name}) + end + + defp maybe_webhooks(children, app_name) do + webhooks = Config.get_webhooks(app_name) + has_webhook_config = is_list(webhooks) and webhooks != [] maybe_set_child(children, has_webhook_config, {Webhooks, app_name: app_name}) end - defp maybe_event_relay(children, configs) do - app_name = Keyword.get(configs, :name) - destinations = Keyword.get(configs, :destinations) - has_event_relay_config = Config.has_config?(destinations, :event_relay_topic) + defp maybe_event_relay(children, app_name) do + event_relay = Config.get_event_relay_topic(app_name) + has_event_relay_config = is_binary(event_relay) and event_relay != "" maybe_set_child(children, has_event_relay_config, {EventRelay, app_name: app_name}) end diff --git a/lib/walex/destinations/webhooks.ex b/lib/walex/destinations/webhooks.ex index b8dcfe6..643f17c 100644 --- a/lib/walex/destinations/webhooks.ex +++ b/lib/walex/destinations/webhooks.ex @@ -43,7 +43,7 @@ defmodule WalEx.Destinations.Webhooks do defp process_events(changes, app_name), do: Enum.map(changes, &process_event(&1, app_name)) defp process_event(change, app_name) do - webhooks = Helpers.get_webhooks(app_name) + webhooks = Config.get_webhooks(app_name) signing_secret = get_signing_secret(app_name) send_webhooks(webhooks, signing_secret, change) diff --git a/lib/walex/event/event.ex b/lib/walex/event/event.ex index 0948858..7939541 100755 --- a/lib/walex/event/event.ex +++ b/lib/walex/event/event.ex @@ -2,7 +2,6 @@ defmodule WalEx.Event do @moduledoc """ Event DSL and casting """ - @derive Jason.Encoder defstruct([:name, :type, :source, :new_record, :old_record, :changes, :timestamp]) @@ -19,7 +18,7 @@ defmodule WalEx.Event do require Logger import WalEx.TransactionFilter - alias WalEx.{Changes, Event, Helpers} + alias WalEx.{Changes, Config, Event, Helpers} @doc """ Macros for processing events @@ -108,7 +107,7 @@ defmodule WalEx.Event do %WalEx.Event.Source{ name: Helpers.get_source_name(), version: Helpers.get_source_version(), - db: Helpers.get_database(app_name), + db: Config.get_database(app_name), schema: schema, table: table, columns: map_columns(columns) diff --git a/lib/walex/helpers.ex b/lib/walex/helpers.ex index d8e0a75..69ccd36 100644 --- a/lib/walex/helpers.ex +++ b/lib/walex/helpers.ex @@ -2,9 +2,6 @@ defmodule WalEx.Helpers do @moduledoc """ Helper functions for WalEx """ - - alias WalEx.Config - def set_type(table, :insert), do: to_string(table) <> ".insert" def set_type(table, :update), do: to_string(table) <> ".update" def set_type(table, :delete), do: to_string(table) <> ".delete" @@ -14,21 +11,4 @@ defmodule WalEx.Helpers do def get_source_name, do: "WalEx" def get_source_version, do: Application.spec(:walex)[:vsn] |> to_string() - - def get_database(app_name), do: Config.get_configs(app_name, :database) - - def get_destination(app_name, destination) do - case Config.get_configs(app_name, :destinations) do - destinations when is_list(destinations) and destinations != [] -> - destinations - |> Keyword.get(destination, nil) - - _ -> - nil - end - end - - def get_webhooks(app_name), do: get_destination(app_name, :webhooks) - - def get_event_relay_topic(app_name), do: get_destination(app_name, :event_relay_topic) end