View Source Bonfire.Common.ExtensionBehaviour behaviour (Bonfire v0.9.10-classic-beta.169)

A Global cache of known Behaviours in Bonfire

Use of the ExtensionBehaviour Service requires declaring @behaviour Bonfire.Common.ExtensionBehaviour in your behaviour module. This module will then index those behaviours and all the modules that implement those behaviours at app startup.

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.

Summary

Callbacks

List modules that implement a behaviour

Functions

Given a behaviour module, filters app modules to only those that implement that behaviour

Note: use apply_modules_cached/2 instead, as it caches the result.

Runs/applies a given function name on each of a list of given modules, returning a map (listing the modules with their result as value) and vice versa (listing the results as key with their calling module as value). It also caches the result on first run.

Returns a specification to start this module under a supervisor.

Populates the global cache with config_module data via introspection.

Callbacks

@callback modules() :: any()

List modules that implement a behaviour

Functions

Link to this function

adopters_of_behaviour(behaviour \\ __MODULE__, app_modules_to_scan \\ app_modules_to_scan())

View Source

Given a behaviour module, filters app modules to only those that implement that behaviour

Link to this function

app_modules_to_scan(opts \\ [])

View Source
Link to this function

apply_modules(modules, fun)

View Source

Note: use apply_modules_cached/2 instead, as it caches the result.

Link to this function

apply_modules_cached(modules, fun)

View Source

Runs/applies a given function name on each of a list of given modules, returning a map (listing the modules with their result as value) and vice versa (listing the results as key with their calling module as value). It also caches the result on first run.

Link to this function

apps_to_scan(opts \\ [])

View Source
Link to this function

behaviour_app_modules(behaviour, behaviours \\ nil)

View Source
Link to this function

behaviour_modules(behaviour, behaviours \\ nil)

View Source

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

find_adopters_of_behaviours(behaviours \\ find_extension_behaviours(), app_modules_to_scan \\ app_modules_to_scan())

View Source
Link to this function

find_extension_behaviours(app_modules_to_scan \\ app_modules_to_scan())

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

Populates the global cache with config_module data via introspection.