View Source Pointers.Tables (bonfire v0.3.5-classic-beta.10)

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, raise NotFound if not found.

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

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, raise NotFound if not found

Look up a schema module by id, name or schema

Populates the global cache with table data via introspection.

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

Get a Table identified by name, id or module.

Link to this section Types

@type 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.

@spec id!(query()) :: integer()

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

@spec id(query()) :: {:ok, integer()} | {:error, Pointers.NotFound.t()}

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

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

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

@spec schema!(query()) :: atom()

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

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

Look up a schema module by id, name or schema

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

Populates the global cache with table data via introspection.

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

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

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

Get a Table identified by name, id or module.