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

Copy Markdown View Source

Behaviour for durable Fly token storage.

Each ExAtlas.Fly.Tokens.AppServer uses a TokenStorage implementation to persist tokens across VM restarts. The default implementation is ExAtlas.Fly.TokenStorage.Dets, a zero-config DETS-backed table. Hosts can swap in their own implementation (e.g. a DB-backed adapter) by setting config :ex_atlas, :fly, token_storage: MyApp.FlyTokenStorage.

Keys

  • :cached — a regular, expiring token acquired via the CLI or ~/.fly/config.yml. Stored with expires_at (unix seconds).
  • :manual — a user-provided override used as a last-resort fallback. Stored without an expiry (expires_at: nil).

Implementations must also return a child_spec/1 so the atlas supervisor tree can start them.

Summary

Types

app_name()

@type app_name() :: String.t()

key()

@type key() :: :cached | :manual

token_record()

@type token_record() :: %{token: String.t(), expires_at: integer() | nil}

Callbacks

child_spec(keyword)

@callback child_spec(keyword()) :: Supervisor.child_spec()

delete(app_name, key)

@callback delete(app_name(), key()) :: :ok

get(app_name, key)

@callback get(app_name(), key()) :: {:ok, token_record()} | :error

put(app_name, key, token_record)

@callback put(app_name(), key(), token_record()) :: :ok