Skip to content

Commit

Permalink
Rename the "Ets" config storage to "ETS" (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide authored Dec 4, 2024
1 parent b78e515 commit 52d3276
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
6 changes: 2 additions & 4 deletions lib/broadway/config_storage.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
defmodule Broadway.ConfigStorage do
@moduledoc false

alias Broadway.ConfigStorage.{Ets, PersistentTerm}

@doc """
Optional setup for the configuration storage
"""
Expand Down Expand Up @@ -36,8 +34,8 @@ defmodule Broadway.ConfigStorage do
@spec get_module() :: module()
def get_module() do
case Application.fetch_env!(:broadway, :config_storage) do
:ets -> Ets
:persistent_term -> PersistentTerm
:ets -> Broadway.ConfigStorage.ETS
:persistent_term -> Broadway.ConfigStorage.PersistentTerm
mod -> mod
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/broadway/config_storage/ets.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Broadway.ConfigStorage.Ets do
defmodule Broadway.ConfigStorage.ETS do
@moduledoc false

@behaviour Broadway.ConfigStorage
Expand Down
21 changes: 12 additions & 9 deletions test/broadway/config_storage_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Broadway.ConfigStorageTest do
use ExUnit.Case, async: false
alias Broadway.ConfigStorage.Ets

alias Broadway.ConfigStorage.ETS

setup do
prev = Application.fetch_env!(:broadway, :config_storage)
Expand All @@ -12,13 +13,15 @@ defmodule Broadway.ConfigStorageTest do

test "ets default options" do
Application.put_env(:broadway, :config_storage, :ets)
Ets.setup()
assert [] = Ets.list()
assert Ets.put("some name", %Broadway.Topology{})
assert ["some name"] = Ets.list()
assert %Broadway.Topology{} = Ets.get("some name")
assert :ets.info(Ets.table(), :size) == 1
Ets.delete("some name")
assert :ets.info(Ets.table(), :size) == 0
ETS.setup()
assert [] = ETS.list()

assert ETS.put("some name", %Broadway.Topology{})
assert ["some name"] = ETS.list()
assert %Broadway.Topology{} = ETS.get("some name")
assert :ets.info(ETS.table(), :size) == 1

ETS.delete("some name")
assert :ets.info(ETS.table(), :size) == 0
end
end

0 comments on commit 52d3276

Please sign in to comment.