From 77e7807d299503f6c9517f8e4367dc8cc53b5c9e Mon Sep 17 00:00:00 2001 From: David Mohl Date: Fri, 7 Jul 2023 16:19:12 +1000 Subject: [PATCH] Remove supervisor --- lib/binance/structs/supervisor.ex | 23 ----------------------- lib/binance/structs/symbol_cache.ex | 26 -------------------------- mix.exs | 2 +- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 lib/binance/structs/supervisor.ex delete mode 100644 lib/binance/structs/symbol_cache.ex diff --git a/lib/binance/structs/supervisor.ex b/lib/binance/structs/supervisor.ex deleted file mode 100644 index 7edb246..0000000 --- a/lib/binance/structs/supervisor.ex +++ /dev/null @@ -1,23 +0,0 @@ -defmodule Binance.Supervisor do - @moduledoc """ - Supervisor for cache and other required persistence layers - """ - - use Supervisor - - def start_link(opts \\ []) do - Supervisor.start_link(__MODULE__, :ok, opts) - end - - def init(:ok) do - children = [ - Binance.SymbolCache - ] - - Supervisor.init(children, strategy: :one_for_one) - end - - def start(_type, _args) do - start_link() - end -end diff --git a/lib/binance/structs/symbol_cache.ex b/lib/binance/structs/symbol_cache.ex deleted file mode 100644 index dff57fb..0000000 --- a/lib/binance/structs/symbol_cache.ex +++ /dev/null @@ -1,26 +0,0 @@ -defmodule Binance.SymbolCache do - @moduledoc """ - Cache for storing symbol names - - Normalization is done by calling the Binance API and retrieving all available symbols. To avoid that this request is done more than once, results are cache inside this module. - """ - - use Agent - - @id :binance_symbol_cache - - def start_link(_opts) do - Agent.start_link(fn -> nil end, name: @id) - end - - def get() do - case Agent.get(@id, fn state -> state end) do - nil -> {:error, :not_initialized} - data -> {:ok, data} - end - end - - def store(data) when is_list(data) do - Agent.update(@id, fn _ -> data end) - end -end diff --git a/mix.exs b/mix.exs index b362f98..ea43cf1 100644 --- a/mix.exs +++ b/mix.exs @@ -22,7 +22,7 @@ defmodule Binance.MixProject do # Run "mix help compile.app" to learn about applications. def application do [ - mod: {Binance.Supervisor, []}, + mod: [], extra_applications: [:logger] ] end