diff options
author | Jordan Bracco <href@random.sh> | 2025-06-25 19:22:59 +0200 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2025-06-25 19:22:59 +0200 |
commit | c934e79e5852e05f714b2d542cc2678e287c49b8 (patch) | |
tree | 55779a0168260fce03e4775eacdd613ffc945588 /lib/plugins/buffer.ex | |
parent | updates (diff) |
format.
Diffstat (limited to '')
-rw-r--r-- | lib/plugins/buffer.ex | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/plugins/buffer.ex b/lib/plugins/buffer.ex index 42a435e..5f848ef 100644 --- a/lib/plugins/buffer.ex +++ b/lib/plugins/buffer.ex @@ -6,7 +6,12 @@ defmodule Nola.Plugins.Buffer do def select_buffer(network, channel, limit \\ 50) do import Ex2ms - spec = fun do {{n, c, _}, m} when n == ^network and (c == ^channel or is_nil(c)) -> m end + + spec = + fun do + {{n, c, _}, m} when n == ^network and (c == ^channel or is_nil(c)) -> m + end + :ets.select(@table, spec, limit) end @@ -18,6 +23,7 @@ defmodule Nola.Plugins.Buffer do for e <- ~w(messages triggers events outputs) do {:ok, _} = Registry.register(Nola.PubSub, e, plugin: __MODULE__) end + {:ok, :ets.new(@table, [:named_table, :ordered_set, :protected])} end @@ -34,11 +40,11 @@ defmodule Nola.Plugins.Buffer do defp ts(nil), do: ts(NaiveDateTime.utc_now()) defp ts(naive = %NaiveDateTime{}) do - ts = naive - |> DateTime.from_naive!("Etc/UTC") - |> DateTime.to_unix() + ts = + naive + |> DateTime.from_naive!("Etc/UTC") + |> DateTime.to_unix() -ts end - end |