MishkaCmsCore.PluginRegistrations (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Keeps every stored plugin registration on the event its module declares.

mishka_installer keeps registrations in Mnesia, on disk, and a plugin that registers again takes its priority, dependencies and extra data from its code but keeps the EVENT it was first stored under. So correcting the event a plugin declares changes nothing on an install that has already run it: the registration still names the old event, the plugin is compiled into that event's chain and no other, and whatever fires the corrected event never reaches it.

reconcile/1 moves each such registration to the declared event and rebuilds both chains. The stored status is kept, so a plugin an operator stopped stays stopped. A registration whose module is not loaded, or declares no event, is left where it is: there is nothing to compare it with.

Attached once on boot via attach/0 (from MishkaCmsCore.Application.start/2); it runs each time mishka_installer finishes synchronizing its plugins, and at once if that has already happened.

Summary

Functions

Attach the reconcile to mishka_installer's synchronized telemetry. Idempotent.

Moves every registration stored under an event its module no longer declares, and returns the plugins it moved.

Functions

attach()

@spec attach() :: :ok

Attach the reconcile to mishka_installer's synchronized telemetry. Idempotent.

reconcile(queue \\ true)

@spec reconcile(boolean()) :: [module()]

Moves every registration stored under an event its module no longer declares, and returns the plugins it moved.

queue is mishka_installer's own: true queues the chain rebuilds, false finishes them before returning.