ExAtlas.Fly.TokenStorage.Dets (ExAtlas v0.5.0)

Copy Markdown View Source

DETS-backed implementation of ExAtlas.Fly.TokenStorage.

Durable, zero-config storage. Survives VM restarts. Writes are serialized through a GenServer to avoid DETS concurrency pitfalls; reads go direct via :dets.lookup/2.

Storage path resolution

  1. opts[:storage_path] at startup.
  2. config :ex_atlas, :fly, storage_path: "...".
  3. Application.app_dir(:ex_atlas, "priv/ex_atlas_fly") — works in dev/test.
  4. Path.join(System.tmp_dir!(), "atlas_fly") — used when the priv dir is read-only (Mix releases commonly are).

Tables

  • :ex_atlas_fly_tokens_cached{app_name, token, expires_at}
  • :ex_atlas_fly_tokens_manual{app_name, token, nil}

If a DETS file fails to open cleanly (e.g. the VM was killed mid-write), open_file is retried with repair: true. If that still fails, the file is deleted and re-created — token data is always re-acquirable, so losing the cache is strictly a perf regression, not a correctness one.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])