Nadia.SessionStore.ETS (nadia v1.6.0)

View Source

Local ETS-backed session store for Nadia bot handlers.

Nadia.SessionStore.ETS is an explicit, supervised process. It owns a private ETS table and implements Nadia.SessionStore for local development and simple single-node bots.

{:ok, pid} = Nadia.SessionStore.ETS.start_link([])
store = {Nadia.SessionStore.ETS, pid}
Nadia.SessionStore.put(store, {:chat, 123}, %{step: :waiting_for_name})

For application supervision, prefer a registered process name:

children = [
  {Nadia.SessionStore.ETS, name: MyApp.BotSessions}
]

store = {Nadia.SessionStore.ETS, MyApp.BotSessions}

This store is not persistent or distributed. Use a custom Nadia.SessionStore backend when sessions must survive restarts or be shared across nodes.

All operations are serialized through the owning GenServer. update/3 is atomic relative to other calls to this store, while a separate get/2 then put/3 sequence is not. Update callbacks block every key and must not call this same store.

Summary

Functions

Starts a local ETS session store.

Types

option()

@type option() :: {:name, GenServer.name()} | {:id, term()}

Functions

start_link(opts \\ [])

@spec start_link([option()]) :: GenServer.on_start()

Starts a local ETS session store.