Skip to content

Add eplugin:wait_for_init/0 to avoid startup race loading plugins

Created by: arekinath

Currently if you are planning to use an eplugin hook during your application startup phase, there is a race between the result of the "provide" cast to eplugin_srv, and the continuation of the startup process. If the cast does not get handled before the startup continues, your hook may run with an empty ets table, and so no plugins are found.

To avoid paying the price of waiting for everyone, when only some situations need to wait, this adds eplugin:wait_for_init/0, which will only return once 'eplugin' is provided in eplugin_srv (ie, all plugins whose dependencies can be met initially at startup are loaded).

Merge request reports