pointers v0.5.0 Pointers.Tables View Source

A Global cache of Tables to be queried by their (Pointer) IDs, table names or Ecto Schema module names.

Use of the Table Service requires:

  1. You have run the migrations shipped with this library.
  2. You have started Pointers.Tables before querying.
  3. All OTP applications with pointable Ecto Schemata to be added to the schema path.
  4. OTP 21.2 or greater, though we recommend using the most recent release available.

While this module is a GenServer, it is only responsible for setup of the cache and then exits with :ignore having done so. It is not recommended to restart the service as this will lead to a stop the world garbage collection of all processes and the copying of the entire cache to each process that has queried it since its last local garbage collection.

Link to this section Summary

Types

A query is either a table's (database) name or (Pointer) ID as a binary or the name of its Ecto Schema Module as an atom.

Functions

Returns a specification to start this module under a supervisor.

Look up a table id by id, name or schema.

Look up a table id by id, name or schema, raise NotFound if not found.

Look up many ids at once, raise NotFound if any of them are not found

Look up a schema module by id, name or schema

Look up a schema module by id, name or schema, raise NotFound if not found

Populates the global cache with table data via introspection.

Get a Table identified by name, id or module.

Look up a Table by name or id, raise NotFound if not found.

Link to this section Types

Specs

query() :: binary() | atom()

A query is either a table's (database) name or (Pointer) ID as a binary or the name of its Ecto Schema Module as an atom.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

id(query()) :: {:ok, integer()} | {:error, TableNotFoundError.t()}

Look up a table id by id, name or schema.

Specs

id!(query()) :: integer()

Look up a table id by id, name or schema, raise NotFound if not found.

Specs

ids!([binary() | atom()]) :: [binary()]

Look up many ids at once, raise NotFound if any of them are not found

Specs

schema(query()) :: {:ok, atom()} | {:error, Pointers.NotFound.t()}

Look up a schema module by id, name or schema

Specs

schema!(query()) :: atom()

Look up a schema module by id, name or schema, raise NotFound if not found

Specs

start_link(ignored :: term()) :: GenServer.on_start()

Populates the global cache with table data via introspection.

Specs

table(query :: query()) ::
  {:ok, Pointers.Table.t()} | {:error, Pointers.NotFound.t()}

Get a Table identified by name, id or module.

Specs

table!(query()) :: Pointers.Table.t()

Look up a Table by name or id, raise NotFound if not found.