View Source Bonfire.Data.AccessControl.Accesses (bonfire v0.3.5-classic-beta.10)

A Global cache of known accesses to be queried by their (Pointer) IDs or name strings.

Use of the Accesses Service requires:

  1. Exporting accesses/0 in relevant modules, returning a keylist of name and (pointer) id.
  2. Start Bonfire.Data.AccessControl.Accesses before querying.
  3. To populate :bonfire_data_access_control, :search_path in config the list of OTP applications where acceses are declared.
  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 access name atom or (Pointer) id binary

Functions

Look up a Access by name or id, throw :not_found if not found.

Get a Access identified by name or id.

Returns a specification to start this module under a supervisor.

Look up a access id by id, name or schema, throw :not_found if not found.

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

Look up many ids at once, throw :not_found if any of them are not found

Populates the global cache with access data via introspection.

Link to this section Types

@type query() :: binary() | atom()

A query is either a access name atom or (Pointer) id binary

Link to this section Functions

@spec access!(query()) :: Bonfire.Data.AccessControl.Access.t()

Look up a Access by name or id, throw :not_found if not found.

@spec access(query :: query()) ::
  {:ok, Bonfire.Data.AccessControl.Access.t()} | {:error, :not_found}

Get a Access identified by name or id.

Returns a specification to start this module under a supervisor.

See Supervisor.

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

Look up a access id by id, name or schema, throw :not_found if not found.

@spec id(query()) :: {:ok, integer()} | {:error, :not_found}

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

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

Look up many ids at once, throw :not_found if any of them are not found

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

Populates the global cache with access data via introspection.