View Source Bonfire.Common.ExtensionBehaviour behaviour (Bonfire v0.9.11-social-beta.6)

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

modules()

@callback modules() :: any()

List modules that implement a behaviour

Functions

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

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

app_modules_to_scan(opts \\ [])

apply_modules(modules, fun)

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

apply_modules_cached(modules, fun)

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.

apps_to_scan(opts \\ [])

behaviour_app_modules(behaviour, behaviours \\ nil)

behaviour_modules(behaviour, behaviours \\ nil)

behaviours()

cached_behaviours()

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

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

find_extension_behaviours(app_modules_to_scan \\ app_modules_to_scan())

populate()

start_link(_)

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

Populates the global cache with config_module data via introspection.