Current section

25 Versions

Jump to

Compare versions

3 files changed
+24 additions
-4 deletions
  @@ -27,5 +27,5 @@
27 27 {<<"name">>,<<"spawn_statestores">>},
28 28 {<<"optional">>,false},
29 29 {<<"repository">>,<<"hexpm">>},
30 - {<<"requirement">>,<<"1.4.1">>}]]}.
31 - {<<"version">>,<<"1.4.1">>}.
30 + {<<"requirement">>,<<"1.4.2">>}]]}.
31 + {<<"version">>,<<"1.4.2">>}.
  @@ -4,6 +4,8 @@ defmodule Statestores.Adapters.Native.CustomMnesiacSupervisor do
4 4
5 5 use Supervisor
6 6
7 + import Statestores.Util, only: [create_directory: 1]
8 +
7 9 def start_link(_) do
8 10 Supervisor.start_link(__MODULE__, [],
9 11 name: Statestores.Adapters.Native.CustomMnesiacSupervisor
  @@ -14,6 +16,24 @@ defmodule Statestores.Adapters.Native.CustomMnesiacSupervisor do
14 16 def init(_) do
15 17 _ = Logger.info("[mnesiac:#{node()}] mnesiac starting, with #{inspect(Node.list())}")
16 18
19 + # If we ever change to Statefulset instead of deployment
20 + # we need to set the mnesia path to be dynamic based on pod name.
21 + # For the time being we only support one storage per system.
22 + if system = System.get_env("PROXY_ACTOR_SYSTEM_NAME") do
23 + # this is necessary to be called on runtime, this will set the
24 + # mnesia path to be dynamic based on configured volume mount
25 + statestore_data_path =
26 + if System.get_env("MIX_ENV") != "prod" do
27 + "#{System.tmp_dir!()}/data/#{system}"
28 +
29 + else
30 + "/data/#{system}"
31 + end
32 +
33 + create_directory(statestore_data_path)
34 + Application.put_env(:mnesia, :dir, statestore_data_path |> to_charlist())
35 + end
36 +
17 37 Mnesiac.init_mnesia(Node.list())
18 38 |> case do
19 39 :ok ->
  @@ -2,7 +2,7 @@ defmodule StatestoresNative.MixProject do
2 2 use Mix.Project
3 3
4 4 @app :spawn_statestores_native
5 - @version "1.4.1"
5 + @version "1.4.2"
6 6 @source_url "https://github.com/eigr/spawn/blob/main/spawn_statestores/statestores_native"
7 7
8 8 def project do
  @@ -58,7 +58,7 @@ defmodule StatestoresNative.MixProject do
58 58 [
59 59 {:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
60 60 {:mnesiac, "~> 0.3"},
61 - {:spawn_statestores, "1.4.1"}
61 + {:spawn_statestores, "1.4.2"}
62 62 ]
63 63 end