From 54a3686e35eeb0cfb0d7fc6ec43030a1def90245 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 7 Feb 2022 20:25:03 -0800 Subject: [PATCH] Extract separate application module - Allows root module to have a public API --- lib/ethereumex.ex | 13 ------------- lib/ethereumex/application.ex | 18 ++++++++++++++++++ mix.exs | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 lib/ethereumex/application.ex diff --git a/lib/ethereumex.ex b/lib/ethereumex.ex index 0816487..f30c9c8 100644 --- a/lib/ethereumex.ex +++ b/lib/ethereumex.ex @@ -4,17 +4,4 @@ defmodule Ethereumex do |> File.read!() |> String.split("") |> Enum.fetch!(1) - - use Application - import Supervisor.Spec, warn: false - - alias Ethereumex.Config - alias Ethereumex.Counter - - def start(_type, _args) do - :ok = Counter.setup() - children = Config.setup_children() - opts = [strategy: :one_for_one, name: Ethereumex.Supervisor] - Supervisor.start_link(children, opts) - end end diff --git a/lib/ethereumex/application.ex b/lib/ethereumex/application.ex new file mode 100644 index 0000000..cb88a92 --- /dev/null +++ b/lib/ethereumex/application.ex @@ -0,0 +1,18 @@ +defmodule Ethereumex.Application do + @moduledoc """ + Configures and starts the :ethereumex OTP application + """ + + use Application + import Supervisor.Spec, warn: false + + alias Ethereumex.Config + alias Ethereumex.Counter + + def start(_type, _args) do + :ok = Counter.setup() + children = Config.setup_children() + opts = [strategy: :one_for_one, name: Ethereumex.Supervisor] + Supervisor.start_link(children, opts) + end +end diff --git a/mix.exs b/mix.exs index 84f0aa6..bbd0505 100644 --- a/mix.exs +++ b/mix.exs @@ -29,7 +29,7 @@ defmodule Ethereumex.Mixfile do [ env: [], extra_applications: [:logger], - mod: {Ethereumex, []} + mod: {Ethereumex.Application, []} ] end