Skip to content

Fixed broken ETS references for short-living processes

Compare
Choose a tag to compare
@Strech Strech released this 19 Jan 09:10
· 92 commits to master since this release

It turns out that when Avrora is used inside Phoenix which controllers are short living processes, that all generated by Avrora.Schema lookup tables (which is in fact erlang term stores) will be cleaned once the controller finishes request processing.

But all the resolved schemas are stored in Avrora.Storage.Memory, which means that after the Phoenix controller dies all the references to ETS inside the Memory module are broken.

This release introduces an ETS host process that will own all the generated stores.

New functionality

A test helper module was added. Since Avrora.Storage.Memory can share state between tests it's always better to ether mock it or clean state. Here is an example:

defmodule MyTest do
  use ExUnit.Case, async: true

  import Avrora.TestCase
  setup :cleanup_storage!

  test "memory storage was filled" do
    asset Avrora.Storage.Memory.get("some") == nil

    Avrora.Storage.Memory.put("some", 42)
    asset Avrora.Storage.Memory.get("some") == 42
  end

  test "memory storage is clean" do
    asset Avrora.Storage.Memory.get("some") == nil
  end
end

Minor changes

  • Some documentation improvements
  • Avrora.Name was renamed to Avrora.Schema.Name