diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c4a436..fa93333 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next +- Rewor trace_started? to not rely on Trace GenServer - Run module/function validations on selected node (thanks @schrockwell) - Upgrade LiveView to v0.18 diff --git a/lib/flame_on/capture/server.ex b/lib/flame_on/capture/server.ex index e0a4e03..fe6b295 100644 --- a/lib/flame_on/capture/server.ex +++ b/lib/flame_on/capture/server.ex @@ -23,7 +23,10 @@ defmodule FlameOn.Capture.Server do singleton to track that it has started for a given capture """ def trace_started? do - GenServer.call(__MODULE__, :trace_started?) + set = ETS.Set.wrap_existing!(__MODULE__) + {:started?, started?} = ETS.Set.get!(set, :started?, {:started?, false}) + if !started?, do: ETS.Set.put!(set, {:started?, true}) + started? end def stop_trace do @@ -31,6 +34,7 @@ defmodule FlameOn.Capture.Server do end def init(%Config{} = config) do + ETS.Set.new!(name: __MODULE__, protection: :public) mock_function(config) starter_block = %Block{id: "starter", function: {config.module, config.function, config.arity}, absolute_start: 0} Process.send_after(self(), :timeout, config.timeout) @@ -74,10 +78,6 @@ defmodule FlameOn.Capture.Server do {:stop, :normal, state} end - def handle_call(:trace_started?, _, %State{trace_started?: started?} = state) do - {:reply, started?, %State{state | trace_started?: true}} - end - def handle_cast(:stop_trace, %State{} = state) do Process.send_after(self(), :do_stop_trace, 1000) {:noreply, state} diff --git a/mix.exs b/mix.exs index 869cb9e..2a27af3 100644 --- a/mix.exs +++ b/mix.exs @@ -54,6 +54,7 @@ defmodule FlameOn.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ + {:ets, "~> 0.9.0"}, {:dialyxir, "~> 1.2.0", only: [:dev, :test], runtime: false}, {:mix_test_watch, "~> 1.1.0", only: :dev, runtime: false}, {:ex_doc, "~> 0.28.0", only: :dev, runtime: false}, diff --git a/mix.lock b/mix.lock index a624056..dbf4926 100644 --- a/mix.lock +++ b/mix.lock @@ -5,6 +5,7 @@ "earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"}, "ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"}, "ex_doc": {:hex, :ex_doc, "0.28.0", "7eaf526dd8c80ae8c04d52ac8801594426ae322b52a6156cd038f30bafa8226f", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e55cdadf69a5d1f4cfd8477122ebac5e1fadd433a8c1022dafc5025e48db0131"}, "expo": {:hex, :expo, "0.1.0", "d4e932bdad052c374118e312e35280f1919ac13881cb3ac07a209a54d0c81dd8", [:mix], [], "hexpm", "c22c536021c56de058aaeedeabb4744eb5d48137bacf8c29f04d25b6c6bbbf45"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},