Dsxir.RuntimeProgram.Store.ETS (dsxir v0.2.0)

Copy Markdown

ETS-backed in-memory implementation of Dsxir.RuntimeProgram.Store.

A GenServer is used solely to own the named ETS table so that it is anchored to a supervisor: ETS tables die with their owner. All reads and writes go directly through :ets, bypassing the GenServer message queue (the table is :public with :read_concurrency).

The store is opt-in: it is not started by the dsxir application. Users start it under their own supervision tree:

children = [
  {Dsxir.RuntimeProgram.Store.ETS,
   name: MyStore, table: :my_runtime_program_table}
]

:name vs :table

The two options are intentionally distinct:

  • :name is the registered name of the owning GenServer process (defaults to __MODULE__).
  • :table is the ETS table atom that callers pass as ref to put/2, get/2, and list/2 (defaults to :dsxir_runtime_program_store).

The ref argument forwarded to Dsxir.RuntimeProgram.from_map/2 via store: {Dsxir.RuntimeProgram.Store.ETS, ref} MUST be the table atom (:table opt), NOT the GenServer name. The two are kept separate so the table can be referenced and queried independently of the owner process (and the owner can be restarted under supervision without callers having to know its pid).

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)

@spec start_link(keyword()) :: GenServer.on_start()