Longbridge.Symbol.Store (longbridge v0.1.0)

Copy Markdown View Source

Long-lived owner of the Symbol.Directory and Symbol.Cache ETS tables.

Both tables are read-mostly and were previously created lazily by whichever process first called ensure_loaded/0. That made the table owner a short-lived caller (e.g. a Task), so when the caller exited the table died and concurrent readers crashed with :ets.member/:undefined (ArgumentError). This GenServer owns the tables so they survive arbitrary caller death.

It is started under Longbridge.Application in production. In contexts where the app is not started (tests, iex), it is started lazily and unlinked on first use so it outlives the process that triggered it.

The tables stay :public, read_concurrency: true, so readers never go through this GenServer — only (re)creation does. ensure_directory/0 / ensure_cache/0 fast-path on :ets.info/1 and only call the owner when the table is missing (e.g. after a test :ets.delete/1).

The actual table creation + loading stays in Symbol.Directory / Symbol.Cache (create_and_load!/0 / create_and_load/0); the owner invokes them so the table is registered to the owner. Directory load failures (missing embedded CSV) are returned to the caller and re-raised there, preserving the original raise contract.

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.