\subsection*{Issue}


\begin{DoxyItemize}
\item Checker plugins see only part of the configuration and cannot check constraints between keys of different mountpoints
\item Notification does not happen once after final commit, but for every plugin
\item Some plugins are not implementable, e.\+g. global locks (that lock before any other plugin and unlock after any other), but also journal plugins that keep track of actions to be done and already done (latter is maybe out of scope for this decision)
\end{DoxyItemize}

\subsection*{Constraints}


\begin{DoxyItemize}
\item Use arrays in configuration and allow arbitrary number of global plugins
\item Plugin interface should be the same. Many plugins, e.\+g. dbus, should work as global plugins w/o any significant change (e.\+g. only one more entry in contract)
\end{DoxyItemize}

\subsection*{Assumptions}


\begin{DoxyItemize}
\item Global plugins to not depend on specific applications nor specific mountpoints.
\item There is no plugin that works as global plugin but will not work as mounted plugin, too (to investigate\+: locker plugins can lead to deadlocks?)
\end{DoxyItemize}

\subsection*{Considered Alternatives}


\begin{DoxyItemize}
\item using different plugin interface (like hooks)
\end{DoxyItemize}

\subsection*{Decision}

Configuration will be in arrays below the keys\+: \begin{DoxyVerb}system/elektra/globalplugins/
    prerollback
    postrollback
    preget
    postget
    preset
    setstorage
    precommit
    postcommit
\end{DoxyVerb}


Plugins state in contract that they will work as global plugin, i.\+e. do not need to work on individual config files, when following contract is present\+: \begin{DoxyVerb}infos/global
\end{DoxyVerb}


The {\ttfamily kdb}-\/tool should have following list-\/like interface\+: \begin{DoxyVerb}kdb global-plugin-add
kdb global-plugin-del
kdb global-plugin-list
\end{DoxyVerb}


\subsection*{Argument}

Some nice features that will be implemented as global plugins.

\subsubsection*{Transformation}

Transformation keys which are read and transformed to be usable by the application\+: \begin{DoxyVerb}[dir/a]
transform=/x
transform/python=...upper()
         /lua=..
\end{DoxyVerb}


(actually two plugins are involved\+: one that fetches transformation keys, the other that executes the transformation code)


\begin{DoxyItemize}
\item preget\+: fetch all foreign keys (kdb\+Get)
\item postget\+: run transformation for all foreign keys
\end{DoxyItemize}

\subsubsection*{Global lock}

simplifies threading and process locking by not having to think about recursive cases.

\subsubsection*{Shell plugins}

Run shell code at end of all plugins, e.\+g. especially doing \begin{DoxyVerb}git add
git commit
\end{DoxyVerb}


\subsubsection*{Inference plugins}

The globbing would be more natural (derived from specification). Or even more advanced ways to copy information from specification to the keys, e.\+g. type inference

\subsubsection*{Journalling plugins}

It should be possible to write plugins which need all file names of all resolver plugins. E.\+g. journalling, global mmap.

\subsection*{Implications}

\subsubsection*{Default global plugins}

Its useful to have some important global plugins, e.\+g. locking by default. Internal list to be used when no system/elektra/global\+\_\+mountpoints/ exists.

State diagrams of plugins need to be redrawn to also include global plugin states.

\subsection*{Related decisions}

\subsection*{Notes}

\subsubsection*{Open Points}


\begin{DoxyItemize}
\item How to test global plugins?
\item locker plugins can lead to deadlocks? (must be avoided by contract?)
\end{DoxyItemize}

\subsection*{Implementation Hints}


\begin{DoxyItemize}
\item add {\ttfamily Plugin $\ast$global\+Plugins \mbox{[}N\+R\+\_\+\+O\+F\+\_\+\+P\+L\+U\+G\+I\+N\+S\mbox{]}} to {\ttfamily \+\_\+\+K\+D\+B}
\item during {\ttfamily kdb\+Open}, {\ttfamily system/elektra/globalplugins/} is read and plugins are constructed and placed into {\ttfamily global\+Plugins}.
\item In kdb\+Get and kdb\+Set hooks execute one of these plugins
\item by default
\begin{DoxyItemize}
\item the plugins are all the same {\ttfamily list} plugins, and their subplugins are executed, when {\ttfamily system/elektra/globalplugins/\+\_\+} states they should be executed
\item a {\ttfamily lock} plugin that executes at begin and end of kdb\+Get and kdb\+Set, respective, i.\+e. postrollback preget postget preset postcommit
\item the {\ttfamily lock} plugin contains the code currently found in resolver 
\end{DoxyItemize}
\end{DoxyItemize}